Skip to content
This repository

Form::field fails when calling Form::label with label options #475

Closed
ericcholis opened this Issue · 5 comments

2 participants

Eric Cholis Nate Abele
Eric Cholis

Title is a bit specific, but if you pass array('label' => array('class' => 'foo', 'any' => 'other options')) for the $options parameter of Form::field you receive the following error
Fatal error: Unsupported operand types in /libraries/lithium/template/helper/Form.php on line 781

I believe that this is because Form::label expects three parameters, ($id, $title, $options). Line 464 calls Form::label with two parameters, passing $options as the second rather than the third.

Nate Abele nateabele closed this
Eric Cholis

Perhaps I'm still confused, but using the syntax outlined by the documentation produces an "Unsupported operand types" error:

echo $this->form->field('firstname', array('label' => array('class' => 'foo')));

The exact example from the documentation produces an Array to String conversion error.

echo $this->form->field('firstname', array('label text' => array('class' => 'foo', 'any' => 'other options')))

Calling Form::config() and setting a class for your desired field does produce the desired result.

$this->form->config(array('label' => array('class' => 'custom-field')));

Is the documentation misleading, or am I missing something entirely?

Nate Abele
Owner

I think you're misreading it.

As indicated by the docs, your options there (i.e. array('label text' => ...)) go under the 'label' key. Lithium has no idea what 'label text' is. :-)

Nate Abele
Owner

Oh, if you have any suggestions on rewording the API docs for clarity, I'm all ears.

Er... eyes.

Eric Cholis

Ah, that would be it, I guess it could be a bit more clear. I think what was confusing was the "label text" part, perhaps it could be changed to "Your Label Text".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.