Hi Michael, Check usage of Zend\Stdlib\Hydrator's... they are supposed to do all this magic for you.
I personally don't like when they translate camelCase to underscores by default but that's another topic. Cheers, Matus On 17 May 2013 15:47, MichaelB <[email protected]> wrote: > Hi all, > > How to fill a form with $form->bind($mymodel) when we have "camelCase" > proprety in model ? > > I use many fields in database with underscore (ex: food_name, is_active, > create_date, ...). > In my model in ZF2 i use camelCase variable like $foodName, $isActive, ... > In my form i use name with underscore like in the database (ex: food_name, > is_active, create_date, ...) > > In the function exchangeArray in my model is like below and work well: > ... > $this->foodName = (isset($data['food_name'])) ? $data['food_name'] : null; > ... > > Now arrive my problem.. I have a form with some fields. Is the "edit" form > so data from database have to fill the form and use $form->bind($mymodel) > BUT all fields with underscore DO NOT FILL because foodName != food_name. > > I must use it for each of my fields to fill my edit form: > $form->get('food_name')->setAttribute('value', $mymodel->foodName); > > > I would like to know if is right ? Or have another solution ? > > > In the doc is only simple variable like id, title, ... but in majority of > project have more complicate variable name. > > Thanks in advance, > Michael > > PS: I hope is clear explanation from my part. > > > > > -- > View this message in context: > http://zend-framework-community.634137.n4.nabble.com/ZF2-Model-with-camelCase-variables-and-edit-form-tp4660045.html > Sent from the Zend Framework mailing list archive at Nabble.com. > > -- > List: [email protected] > Info: http://framework.zend.com/archives > Unsubscribe: [email protected] > > >
