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

Closed
ericcholis opened this Issue May 23, 2012 · 5 comments

2 participants

@ericcholis
Contributor

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.

@nateabele nateabele closed this May 24, 2012
@ericcholis
Contributor

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?

@nateabele
Member

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. :-)

@nateabele
Member

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

Er... eyes.

@ericcholis
Contributor

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