0

drupal_validate_form is not validating required validation when i was creating a node programatically .

Can any one say, it is design like that or am i doing something wrong .

        $node_form = (object) array(
            'type' => 'MY_CONTENT_TYPE',
            'language' => LANGUAGE_NONE,
        );
        $form = drupal_get_form('application_node_form',$node_form);
        $old_fs = @unserialize($r->form_state);
        $form_state = array();
        $form_state['values'] = $old_fs['values'];
        $form_state['values']['op'] = t('Save');
        $form_state['submitted'] = 1;
        $form_state['complete form'] = array();
        $form_state['triggering_element'] = array('#parents'=>array('next'),'#button_type'=>'submit');
        unset($form['#token']);
        drupal_validate_form('MY_CONTENT_TYPE_node_form', $form, $form_state);
1

You can check if the form failed validation by calling form_get_errors

You could try using drupal_form_submit instead, which I think will also validate the form (seen via form_get_errors)

  • yes but drupal_form_submit check the form validation and after that it will save it if validation have no error. – Lucifer Sep 18 '14 at 6:52
  • oh my goodness what i was trying is a multi step form so if the 1st tab is validate then form is validate – Lucifer Oct 29 '14 at 11:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.