/Implementing the hook menu//
function gallery_menu() {
$items = array();
$items['gallerysadd'] = array(
'title' => 'Test Module WWC',
'page callback' => 'wwc_test_gallery',
'access callback' => 'user_access',
'access arguments' => array('access content'),
);
return $items;
}
//calling the drupal form
function wwc_test_gallery(){
return(drupal_get_form('upload_Gallery_form'));
}
//custome the form
function upload_Gallery_form($form, &$form_state){
$form['private_gallery'] = array(
'#prefix' => '<div id="privategallery-fieldset-wrapper">',
'#suffix' => '</div>',
'#type' => 'fieldset',
'#title' => t('Gallery'),
);
if (empty($form_state['num_private_gallery'])) {
$form_state['num_private_gallery'] = 1;
}
for ($i = 0; $i < $form_state['num_private_gallery']; $i ++) {
$form['private_gallery']['privategallery' . $i] = array(
'#name' => 'files[privategallery' . $i . ']',
'#type' => 'managed_file',
'#title' => t(''),
'#upload_location' => 'public://cruisetemplates/',
'#default_value' => $privategalleryArray[$i]
);
}
$form['private_gallery']['privateevent_addgallery'] = array(
'#name' => 'private_gallery',
'#type' => 'submit',
'#value' => t('Add one more Gallery'),
'#submit' => array('ajax_add_private_gallery_submit'),
'#ajax' => array(
'callback' => 'ajax_add_private_gallery_callback',
'wrapper' => 'privategallery-fieldset-wrapper'
)
);
return $form;
}
//calling the ajax function when ajax and retun the form
function ajax_add_private_gallery_callback($form, $form_state) {
return $form['private_gallery'];
}
//submit rebuit the form
function ajax_add_private_gallery_submit($form, &$form_state) {
$form_state['num_private_gallery'] ++;
$form_state['rebuild'] = TRUE;
}
function gallery_menu() {
$items = array();
$items['gallerysadd'] = array(
'title' => 'Test Module WWC',
'page callback' => 'wwc_test_gallery',
'access callback' => 'user_access',
'access arguments' => array('access content'),
);
return $items;
}
//calling the drupal form
function wwc_test_gallery(){
return(drupal_get_form('upload_Gallery_form'));
}
//custome the form
function upload_Gallery_form($form, &$form_state){
$form['private_gallery'] = array(
'#prefix' => '<div id="privategallery-fieldset-wrapper">',
'#suffix' => '</div>',
'#type' => 'fieldset',
'#title' => t('Gallery'),
);
if (empty($form_state['num_private_gallery'])) {
$form_state['num_private_gallery'] = 1;
}
for ($i = 0; $i < $form_state['num_private_gallery']; $i ++) {
$form['private_gallery']['privategallery' . $i] = array(
'#name' => 'files[privategallery' . $i . ']',
'#type' => 'managed_file',
'#title' => t(''),
'#upload_location' => 'public://cruisetemplates/',
'#default_value' => $privategalleryArray[$i]
);
}
$form['private_gallery']['privateevent_addgallery'] = array(
'#name' => 'private_gallery',
'#type' => 'submit',
'#value' => t('Add one more Gallery'),
'#submit' => array('ajax_add_private_gallery_submit'),
'#ajax' => array(
'callback' => 'ajax_add_private_gallery_callback',
'wrapper' => 'privategallery-fieldset-wrapper'
)
);
return $form;
}
//calling the ajax function when ajax and retun the form
function ajax_add_private_gallery_callback($form, $form_state) {
return $form['private_gallery'];
}
//submit rebuit the form
function ajax_add_private_gallery_submit($form, &$form_state) {
$form_state['num_private_gallery'] ++;
$form_state['rebuild'] = TRUE;
}
No comments:
Post a Comment