HI,
Question about not reusing a variable name. You're talking about the name
you give the actual dijit element right? Like for example.
$this->addElement('ValidationTextBox', 'name', array(
'validators' => array(
array('StringLength', false, array(0, 255)),
),
'label' => 'Name:',
'required' => true,
'invalidMessage' => 'ERROR MESSAGE HERE',
'trim' => true,
));
here the element name is 'name'
so i'm curious as to how you do two things if you were to attach a microtime
to the 'name'
1. if you wanted to use $form->populate($formData) to populate these fields,
how would you do that? From what I understood (and had working) you match
the dijit element name to the database field name and it can find and
populate that field for you. That wouldn't work in this case if you added
microtime right?
2. when it comes time to process the data from your form, how do you access
this 'name' variable now?
For example in my form processing code I do...
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
....
$row->name = $formData['name'];
.....
$row->save();
}
This also wouldn't work right? cause my new form item has a name with a
microtime connected.
Am I missing something?
Thanks!!
MarkDNA wrote:
>
> Thank you. That works. One thing that others should be aware of when
> returning a container with dijit elements is the fact that dojo does NOT
> like to reuse the IDs. i.e., if your variable name is lineItemSize, you
> will need to set the ID/name of the element to something that is unique
> every time you return that container - including the first time the page
> is rendered. In my inline -editing example, I am adding the microtime to
> the end of every element name. This guarantees that when they edit that
> line and click the edit button to set off the xhrPost, the returned form
> has IDs that are different from the first time the page rendered. If you
> don't do this, you will get something like following error:
>
> An error occurred: Error: Tried to register widget with id==lineItemSize
> but that id is already registered
>
> -Mark
>
>
> Matthew Weier O'Phinney-3 wrote:
>>
>> Second, for XHR requests, I always have my view use declarative Dojo
>> syntax:
>>
>> Zend_Dojo_View_Helper_Dojo::setUseDeclarative();
>>
>> This ensures that you can run the dojo parser over the returned markup.
>> Returning and executing Javascript from XHR is often considered a
>> security issue, and can additionally be difficult to get to work
>> correctly.
>>
>> This leads to my third point: you'll need to run the dojo parser again
>> *after* you've inserted the new HTML into your DOM. This is done with
>> the following call:
>>
>> dojo.parser.parse();
>>
>> You can actually run the parser on a containing node as well. So, if
>> you did something like the following with the response payload:
>>
>> var formContainer = dojo.byId('form-container');
>> formContainer.innerHTML = data;
>>
>> then you'd call this immediately following:
>>
>> dojo.parser.parse(formContainer);
>>
>> Hope that helps answer your question!
>>
>> --
>> Matthew Weier O'Phinney
>> Software Architect | [email protected]
>> Zend Framework | http://framework.zend.com/
>>
>
>
--
View this message in context:
http://www.nabble.com/Dijit-elements-and-xhrPost-tp20276334p22326284.html
Sent from the Zend Framework mailing list archive at Nabble.com.