<div class="gmail_quote">On Sat, Sep 17, 2011 at 6:07 PM, Kayode Odeyemi <span dir="ltr">&lt;<a href="mailto:dreyemi@gmail.com">dreyemi@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

Hello,<br><br>I&#39;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&#39;t know why I&#39;m getting this because the index is there and works for other blocks I have created that way.<i> </i>I&#39;m also following the ajax_examples module in the examples module.<br><i><br></i>Below is the snippet I&#39;m working with:<br>


<br>function uec_core_block_configure($delta = &#39;&#39;) {<br>  $form = array();<br>    switch($delta) {<i><br></i>case &#39;uec_core_socials&#39;:<br>
                $form[&#39;#tree&#39;] = TRUE;<br>                $form[&#39;files_fieldset&#39;] = array(<br>                    &#39;#type&#39; =&gt; &#39;fieldset&#39;,<br>                    &#39;#title&#39; =&gt; t(&#39;Upload social icons&#39;),<br>



                    // Set up the wrapper so that AJAX will be able to replace the fieldset.<br>                    &#39;#prefix&#39; =&gt; &#39;&lt;div id=&quot;names-fieldset-wrapper&quot;&gt;&#39;,<br>                    &#39;#suffix&#39; =&gt; &#39;&lt;/div&gt;&#39;,<br>



                );<br>                // Build the fieldset with the proper number of files. We&#39;ll use<br>                // $form_state[&#39;num_files&#39;] to determine the number of managed_file fields to build.<br>



                if (empty($form_state[&#39;num_files&#39;])) {<br>                    $form_state[&#39;num_files&#39;] = 1;<br>                }<br>                // provide ability to add more files<br>                for ($i = 0; $i &lt; $form_state[&#39;num_files&#39;]; $i++) {<br>



                    $form[&#39;files_fieldset&#39;][&#39;uec_core_socials_block_image&#39;][$i] = array(<br>                        &#39;#type&#39; =&gt; &#39;managed_file&#39;,<br>                        &#39;#title&#39; =&gt; t(&#39;Image&#39;),<br>



                        &#39;#description&#39; =&gt; t(&#39;Upload an image to represent social icons, allowed extensions: jpg, jpeg, png, gif&#39;),<br>                        &#39;#default_value&#39; =&gt; variable_get(&#39;uec_core_socials_block_image&#39;,  &#39;&#39;),<br>



                        &#39;#element_validate&#39; =&gt; array(&#39;uec_core_socials_block_image_validate&#39;),<br>                        &#39;#upload_location&#39; =&gt; &#39;public://&#39; //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[&#39;files_fieldset&#39;][&#39;add_file&#39;] = array(<br>                    &#39;#type&#39; =&gt; &#39;submit&#39;,<br>                    &#39;#value&#39; =&gt; t(&#39;Add one more&#39;),<br>



                    &#39;#submit&#39; =&gt; array(&#39;uec_core_socials_add_more_add_one&#39;),<br>                    // See the examples in ajax_example.module for more details on the<br>                    // properties of #ajax.<br>



                    &#39;#ajax&#39; =&gt; array(<br>                        &#39;callback&#39; =&gt; &#39;uec_core_socials_add_more_callback&#39;,<br>                        &#39;wrapper&#39; =&gt; &#39;names-fieldset-wrapper&#39;,<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[&#39;files_fieldset&#39;];<br>}<br><br>/**<br> * Submit handler for the &quot;add-one-more&quot; button.<br> *<br> * Increments the max counter and causes a rebuild.<br>



 */<br>function uec_core_socials_add_more_add_one($form, &amp;$form_state) {<br>  $form_state[&#39;num_files&#39;]++;<br>  $form_state[&#39;rebuild&#39;] = TRUE;<br>}<br><br>function uec_core_socials_block_image_validate($form, &amp;$form_state) {<br>



    variable_set(&#39;uec_core_socials_block_image&#39;, $form_state[&#39;values&#39;][&#39;files_fieldset&#39;][&#39;uec_core_socials_block_image&#39;]);<br>    //variable_set(&#39;uec_core_socials_block_image&#39;, $form_state[&#39;values&#39;][&#39;uec_core_socials_block_image&#39;]);<br>



}<br clear="all"><br>I&#39;ll like to know what I&#39;m doing wrong.<font color="#888888"><br></font></blockquote><div><br>I was able to fix it with this:<br><br>variable_set(&#39;uec_core_socials_block_image&#39;, $form_state[&#39;values&#39;][&#39;settings&#39;][&#39;files_fieldset&#39;][&#39;uec_core_socials_block_image&#39;]); <br>

</div></div><br><br clear="all"><br>-- <br>Odeyemi &#39;Kayode O.<br><a href="http://www.sinati.com" target="_blank">http://www.sinati.com</a>. t: @charyorde<br><br>