Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render launch exception to input field #21

Closed
eusonlito opened this issue Jul 25, 2014 · 2 comments
Closed

render launch exception to input field #21

eusonlito opened this issue Jul 25, 2014 · 2 comments

Comments

@eusonlito
Copy link
Contributor

Tendo este código:

$form = new Form;

$form->add([
    'name' => Input::text()->required()->attr([
        'placeholder' => _('Name')
    ])
]);

foreach ($form as $input) {
    $input->class('form-control');
    $input->label($input->attr('placeholder'));

    $input->render(function ($input, $label, $labelError) {
        return "<div class='field'>$label $input $labelError</div>";
    });
}

return $form;

O resultado é:

Method FormManager\Inputs\File::__toString() must not throw an exception
FormManager/Traits/CollectionTrait.php
@oscarotero
Copy link
Owner

In php you cannot throw exceptions in __toString() magic method (https://bugs.php.net/bug.php?id=50699)

In your code you are using "Input" classes instead "Field". Inputs represent <input> elements and they don't have render method, so you are really creating a "render" attribute with a function as value. On convert the input to string, this attribute throws an exception (you cannot convert a function to a string).

@eusonlito
Copy link
Contributor Author

Ok, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants