Hello,<br><br>I'm trying to provide the ability to upload more than one file in the configuration of one of my custom blocks. <br>I got the basics, but everytime I click on upload button, I get this:<br><br><i>Notice</i>: Undefined index: uec_core_socials_block_image in <i>uec_core_socials_block_image_validate()<br>
</i><i>Notice</i>: Undefined index: files_fieldset in <i>uec_core_socials_block_image_validate() </i><br><i>
<br></i>I don't know why I'm getting this because the index is there and works for other blocks I have created that way.<i> </i>I'm also following the ajax_examples module in the examples module.<br><i><br></i>Below is the snippet I'm working with:<br>
<br>function uec_core_block_configure($delta = '') {<br> $form = array();<br> switch($delta) {<i><br></i>case 'uec_core_socials':<br>
$form['#tree'] = TRUE;<br> $form['files_fieldset'] = array(<br> '#type' => 'fieldset',<br> '#title' => t('Upload social icons'),<br>
// Set up the wrapper so that AJAX will be able to replace the fieldset.<br> '#prefix' => '<div id="names-fieldset-wrapper">',<br> '#suffix' => '</div>',<br>
);<br> // Build the fieldset with the proper number of files. We'll use<br> // $form_state['num_files'] to determine the number of managed_file fields to build.<br>
if (empty($form_state['num_files'])) {<br> $form_state['num_files'] = 1;<br> }<br> // provide ability to add more files<br> for ($i = 0; $i < $form_state['num_files']; $i++) {<br>
$form['files_fieldset']['uec_core_socials_block_image'][$i] = array(<br> '#type' => 'managed_file',<br> '#title' => t('Image'),<br>
'#description' => t('Upload an image to represent social icons, allowed extensions: jpg, jpeg, png, gif'),<br> '#default_value' => variable_get('uec_core_socials_block_image', ''),<br>
'#element_validate' => array('uec_core_socials_block_image_validate'),<br> '#upload_location' => 'public://' //If this is not set, the file will be uploaded to temporary dir. Then use file_move to move it to drupal default file system location<br>
);<br> }<br> $form['files_fieldset']['add_file'] = array(<br> '#type' => 'submit',<br> '#value' => t('Add one more'),<br>
'#submit' => array('uec_core_socials_add_more_add_one'),<br> // See the examples in ajax_example.module for more details on the<br> // properties of #ajax.<br>
'#ajax' => array(<br> 'callback' => 'uec_core_socials_add_more_callback',<br> 'wrapper' => 'names-fieldset-wrapper',<br>
),<br> );<br> break;<br> }<br> return $form;<br>}<br><br><br>/**<br> * Callback for both ajax-enabled buttons.<br> *<br> * Selects and returns the fieldset with the names in it.<br>
*/<br>function uec_core_socials_add_more_callback($form, $form_state) {<br> return $form['files_fieldset'];<br>}<br><br>/**<br> * Submit handler for the "add-one-more" button.<br> *<br> * Increments the max counter and causes a rebuild.<br>
*/<br>function uec_core_socials_add_more_add_one($form, &$form_state) {<br> $form_state['num_files']++;<br> $form_state['rebuild'] = TRUE;<br>}<br><br>function uec_core_socials_block_image_validate($form, &$form_state) {<br>
variable_set('uec_core_socials_block_image', $form_state['values']['files_fieldset']['uec_core_socials_block_image']);<br> //variable_set('uec_core_socials_block_image', $form_state['values']['uec_core_socials_block_image']);<br>
}<br clear="all"><br>I'll like to know what I'm doing wrong.<br>-- <br>Odeyemi 'Kayode O.<br><a href="http://www.sinati.com" target="_blank">http://www.sinati.com</a>. t: @charyorde<br><br>