To: Dincho
Oh~~Cool, It's work. Thank you so much.
On 5月22日, 下午7時55分, Dincho Todorov <[EMAIL PROTECTED]> wrote:
> On May 22, 9:58 am, Cipher Chien <[EMAIL PROTECTED]> wrote:
>
>
>
> > Hi,
>
> > I'm trying to write a form generator without yaml. my code is:
>
> > in indexSuccess.php
> > <?php
> > use_helper('Validation');
> > echo form_error('name');
> > echo form_tag('contact/send')
> > ?>
> > Name: <?php echo input_tag('name') ?><br />
> > <?php echo submit_tag() ?>
> > </form>
>
> > in actions.class.php
> > <?php
> > ...
> > public function handleErrorSend(){
> > $this->forward('contact', 'index');
>
> > }
>
> > public function validatorSend(){
> > $name = $this->getRequestParameter('name');
> > $error = null;
>
> > $myValidator = new sfStringValidator();
> > $myValidator->initialize($this->getContext(),array(
> > 'min'=>2,
> > 'min_error' => 'This name is too short (2 characters minimum)',
> > 'max' => 4,
> > 'max_error' => 'This name is too long. (100 characters maximum)'
> > ));
> > if (!$myValidator->execute($name,$error)) {
> > return false;
> > }
>
> > return true;}
>
> > ?>
>
> > When I input a string lenth less then 2 or over then 4, the page will
> > go back to the form, but it didn't show any error message.
> > I know it can be solved if I use yaml to set the form validation, but
> > I want user can change the validation rule by them self. so I will use
> > database.
>
> > My question is how to get the error message?
>
> Hi,
> try with this:
>
> .....
> if (!$myValidator->execute($name,$error)) {
> $this->getRequest()->setError('name', $error);
> return false;
> }
> .....
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---