multi step form with upload & save to node type

为君一笑 提交于 2019-12-20 06:15:06

问题


im trying about a week to do multistep form usin form api in drupal 6 and in the step 2 there is 2 upload fields and then its should proceed until step 5, after user fill the step 1 he can skip the whole form and submit the data... im trying to do it and im not success, i glue some pices of code and its not work , and multiform plugin is kinda buggy anyone did something like that and can share the code or just explain me what functions i should use and how?


回答1:


Try multiform, but be careful as it is still in dev state.

If you want to do it on your own, have a storage variable called step in the form which represents the current step, and increment it everytime this function is called.

// if **step** is not set, make it 0, else increment it by 1.
$step = isset($form_state['values']) ? (int)$form_state['storage']['step'] : 0;
$form_state['storage']['step'] = $step + 1; 

Use a switch case to render the form elements for the current step. If it is not last step dispaly next button, else submit button. Move the values from $form_state['values'] to $form_state['storage']

In the submit function, perform the database insertion if it is the last step else just return.



来源:https://stackoverflow.com/questions/5185961/multi-step-form-with-upload-save-to-node-type

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!