Submit ajax form with custom method or handle?

Notice: This thread is very old.
droa22
Member | 6
+
0
-

Imagine one component that make one view with snippets and one form submitted with ajax.
What is the best solution when I have form that makes changes in one snippet of the same view?.

<?php
protected function createComponentMyCustomForm()
{
	$form = new MyCustomForm();
	$form->onSuccess[] = array($this, 'myCustomFormSubmitted');
	return $form;
}

public function myCustomFormSubmitted(MyCustomForm $form)
{
	//some changes in db with form values
	$this->redrawControl('mySnippet');
}
?>

or

<?php
protected function createComponentMyCustomForm()
{
	$form = new MyCustomForm();
	$form->onSuccess[] = array($this, 'handleMyCustomFormSubmitted');
	return $form;
}

public function handleMyCustomFormSubmitted(MyCustomForm $form)
{
	//some changes in db with form values
	$this->redrawControl('mySnippet');
}
?>

the template:

<?php
{control registrationForm, class => 'ajax'}

{snippet mySnippet}
	{* Show some data from db *}
{snippet}
?>
Pavel Kravčík
Member | 1180
+
+1
-

I prefer first example, cause there will be no problem if you do this in template:

n:href="handleMyCustomFormSubmitted!"