This video is part 2 of my introduction to Zend_Form. These last two videos have been a bit long since Zend_Form has a lot of behavior.
I’ve also included the source code for this video. Hopefully this will help you follow along.
download the source here, I haven’t included the Zend Framework itself, but I imagine you can grab a copy off of the Zend website.
Description
This video is part 2 of my introduction to Zend_Form. These last two videos have been a bit long since Zend_Form has a lot of behavior. I’ve also included the source code for this video. Hopefully this will help you follow along. download the source here, I haven’t included the Zend Framework itself, but I…
Tags
crud, dto, Forms, validation
Related
Thanks for video and very thanks for source )
Hey, I ran into an error with the sample code running under PHP 5.2.6 that you might want to checkout. In the App_forms_ItemEditor __construct method you type the first parameter to int. When I tried to run the code example I got an error like:
Catchable fatal error: Argument 1 passed to App_forms_ItemEditor::__construct() must be an instance of int, integer given, called in /application/controllers/ItemController.php on line 28 and defined in /library/App/forms/ItemEditor.php on line 10
In doing some Googling the explanation I found claims:
“Type Hints can only be of the object and array (since PHP 5.1) type. Traditional type hinting with int and string isn’t supported.”
http://de2.php.net/manual/en/language.oop5.typehinting.php
Hi Adam,
Thanks for mentioning this. I try and make my code as specific as possible, but I didn’t know that traditional types weren’t supported.
No worries, I had no idea either. Looks like it was changed as of 5.1? I couldn’t really get a lot of details. I feel strong data typing is a good thing, so I am not sure why they would not allow it. Seems backwards to me.
I got an error when back to index from delete because this line
$this->session->items[$this->getRequest()->getParam('id')] = null;
do not delete the record
I changed the code to
unset( $this->session->items[$this->getRequest()->getParam('id')] );
this one works fine.
Maybe somebody will be interested….
I liked the part at the end when you repeated that you will post the source code to ZC.
Really like your screencasts.
Nice tutorial(s). Thanks!
There is no need to set up routes when sending ID in URI.
Instead of using
/items/edit/1
you href URI as
/items/edit/id/1
and in controller you get it by
$this->_request->getParam(‘id’, -1);
(-1 would be the default value if param ‘id’ is not present)
The general form is
[/module]/controller/action/param1/value1/param2/value2/…
and getting them
$this->_request->getParam(‘param1′, ‘none’);
$this->_request->getParam(‘param2′, 0);
This way the cast might be simpler and more focused on the content – forms.
I could kiss you!!! Well… almost, that would make me gay.
This was the 1st video where you actually failed to show all the text on the recorded area. Shame on you i believed you where perfect!!! I mean you have been so far.
Jokes aside! Thank you kind sir for this excelent sets of video tutorials, i have nothing to point apart for the text being out of the screen in the routes bit which basicly means… YOU ARE GOD!!!!!
Thank you man!
hehehehe… I think a couple more quotes like this will merit a testimonials page. Thank you!
Hey Jon,
don’t know where to ask this question on ur site. But still what is a best practice to deal with Zend_file_transfer_adapter / zend_form_element_file when u need to normalize the name of the file that is being uploaded. In docs it says that adding a filter to File_transfer_element has to be done after validation so it kind a brings an idea to add a Filter in the Controller (action), which is kind a odd for me. As for me the Whole Form object and it is elements have to know how to do things (in case rename the filename/normilize it) and in controller we have to care mostly about business logic.
any comment is appreciated …simple
To be honest, I’ve never used the File_transfer_element, so I can’t really comment on it. You’re right that what they’re suggesting would muddy up the controller. Alternatively, you could create a public function isValid($params); method in your form object that calls the parent::isValid($params) method in your form object. This way, you could do the filtering / receiving code after checking to see if all other form elements are valid.
Hello, Jon
I’ve found your Zend casts very useful. But with this video I have an issue. When I create an App_forms_itemEditor object I get two identical forms on a page instead of one. If I remove addElements string from ItemEditor constructor I get one form but it doesn’t work properly with data. Please tell me what I do wrong.
Thanks