Giter VIP home page Giter VIP logo

html's Introduction

laravie

Gitter

html's People

Contributors

adambant avatar adamgoose avatar alexandre-butynski avatar anahkiasen avatar andersonfriaca avatar barryvdh avatar crynobone avatar darthrevan13 avatar devinfd avatar franzliedke avatar grahamcampbell avatar greggilbert avatar jackmcdade avatar lanort avatar lucasmichot avatar mlantz avatar mul14 avatar nickurt avatar patrickbrouwers avatar pjona avatar ranabd36 avatar robinmalfait avatar taylorotwell avatar thujohn avatar tortuetorche avatar tshafer avatar vendin avatar vinceg avatar vlakoff avatar yajra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

html's Issues

Form model binding not working in blade components

Form model binding not working in blade components

Form model binding is not working when you create a form component:

@component('components.form', ['model' => $product ?? null, 'route' => 'products'])
  @component('components.form-group', ['name' => 'name', 'label' => 'Product name:'])
    {!! Form::text('name', null, ['class' => 'form-control']) !!}
  @endcomponent
@endcomponent

And components/form.blade.php looks like this:

{!! Form::model($model, ['method' => 'PATCH', 'route' => [$route . '.update', $model->id]]) !!}
  {!! $slot !!}
{!! Form::close() !!}

In this case the field values are not populating (the attributes are exist in the $model object). When I use Form::model() just where I make the fields, it's working fine. If I @include the form opener part, it's also working fine.

Thank you.

trait FormAccessible bug ? (version 5.8.2)

Hi there,
This is probably just a misunderstanding of my part but there's something strange related to the FormAccessible trait when dealing with relations.

First of all, is this trait supposed to be dealing with relations ? Or is the developer expected to write form mutators for relations ? If so, just ignore this :)

So I've got this model that defines a relation :

class Content {

    use FormAccessible;

    public function content_type()
    {
        return $this->belongsTo(ContentType::class);
    }
}

if I call $content->getFormValue('content_type') it returns null, because :
1 - there is no form mutator for content_type in this model
2 -The FormAccessible trait sees 'content_type' as a nested key and forward the call like so :
return \data_get($relatedModel, empty($key) ? null : $key); with, in this case, $relatedModel being a ContentType object and $key being still 'content_type'.
Obviously there is no 'content_type' attribute on the ContentType object.

Moreover, if I call $content->getFormValue('content_type.id') it's searching for a form mutator in ContentType called formContentType.idAttribute on the ContentType object, which isn't a valid php method name.

Wouldn't it make more sense to return the ContentType object when there is no form mutator in that object, or even better the key of the relation if the key isn't a nested key ?

So it would do :

$content->getFormValue('content_type'); //returns the primary key of the ContentType object
$content->getFormValue('content_type.name'); //returns a string or the result of the method formNameAttribute of the ContentType object

What do you think ?

Laravel 9 compatibility

  • Package Version: dev-master
  • Laravel Version: 9
  • PHP Version: 8.1

Description:

Hello,

I try to install the library on Laravel 9 but I have the following errors:

Problem 1
    - illuminate/view[v7.0.0, ..., v7.28.4] require php ^7.2.5 -> your php version (8.1.0) does not satisfy that requirement.
    - illuminate/view[v8.0.0, ..., v8.11.2] require php ^7.3 -> your php version (8.1.0) does not satisfy that requirement.
    - Root composer.json requires laravie/html dev-master -> satisfiable by laravie/html[dev-master].
    - Conclusion: don't install laravel/framework v9.3.0 (conflict analysis result)
    - Conclusion: don't install laravel/framework v9.3.1 (conflict analysis result)
    - Conclusion: don't install laravel/framework v9.2.0 (conflict analysis result)
    - laravie/html dev-master requires illuminate/view ^7.0 || ^8.0 -> satisfiable by illuminate/view[v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev].
    - Only one of these can be installed: illuminate/view[v7.0.0, ..., 7.x-dev, v8.0.0, ..., 8.x-dev], laravel/framework[v9.2.0, v9.3.0, v9.3.1, 9.x-dev]. laravel/framework replaces illuminate/view and thus cannot coexist with it.
    - Root composer.json requires laravel/framework ^9.2 -> satisfiable by laravel/framework[v9.2.0, v9.3.0, v9.3.1, 9.x-dev].

Can you update your library for Laravel 9?

Thank you!

Trait Componentable missing a use statement

When using renderComponent, it tries to return an instance that implements "Htmlable".
But since it is not aliased, an ErrorException is thrown:

Type error: Return value of Collective\Html\FormBuilder::renderComponent() must be an instance of Collective\Html\Htmlable, instance of Illuminate\Support\HtmlString returned

After adding

use Illuminate\Contracts\Support\Htmlable;

into src/Componentable.php, the problem disappears as expected.

Selection selected ignores Collection class

Hey,

Seems like there is a bug with the the following method:

https://github.com/laravie/html/blob/master/src/Concerns/Selection.php#L203

Assuming the following code as an example.

getSelectedValue(1, collect([1,2,3]))

the first lines in the method mentioned above will kick in for arrays as well as collections since Collection implements Arrayable.

the code

} elseif ($selected instanceof Collection) {
            return $selected->contains($value) ? 'selected' : null;
        }

never executes for Collections.

The following seems to work

/**
     * Determine if the value is selected.
     *
     * @param  string|null $value
     * @param  string|iterable|null  $selected
     *
     * @return string|null
     */
    protected function getSelectedValue(?string $value, $selected): ?string
    {
        if ($selected instanceof Collection) {
            return $selected->contains($value) ? 'selected' : null;
        } elseif ($selected instanceof Arrayable) {
            $selected = $selected->toArray();
        }

        if (is_array($selected)) {
            return in_array($value, $selected, true) || in_array((string) $value, $selected, true)
                        ? 'selected'
                        : null;
        }

        return ((string) $value === (string) $selected) ? 'selected' : null;
    }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.