Welcome Guest, Not a member yet? Register   Sign In
drop downs, array syntax name, re-population
#4

[eluser]theprodigy[/eluser]
ok, I think I got it. If there is a more effecient way of doing it, I'm all ears, but here is how I did it.
Controller:
the name of the element is 'actors[]', but I need to grab it by 'actors' (without the [])
Code:
$this->data['actors_submitted'] = array();
if($this->input->post('actors'))
{
    $this->data['actors_submitted'] = $this->input->post('actors');
}
View:
Code:
<?php
            if(! empty($actors_submitted))
            {
                $id = 1;
                foreach($actors_submitted as $actor)
                {
                    echo form_dropdown('actors[]', $actors, $actor, 'id="actor_' . $id . '"');
                    if($id == 1)
                    {
                        echo '<a href="#">+</a>';
                    }
                    if($id < count($actors_submitted))
                    {
                        echo '<br />';
                    }
                    $id++;
                }
            }
            else
            {
                echo form_dropdown('actors[]', $actors, '', 'id="actor_1"') . '<a href="#">+</a>';
            }
        ?&gt;


Messages In This Thread
drop downs, array syntax name, re-population - by El Forum - 05-18-2010, 06:39 PM
drop downs, array syntax name, re-population - by El Forum - 05-18-2010, 06:46 PM
drop downs, array syntax name, re-population - by El Forum - 05-18-2010, 06:58 PM
drop downs, array syntax name, re-population - by El Forum - 05-18-2010, 07:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB