[eluser]Wievior[/eluser]
Wow, that's extremely impressive!
What I came up with was using jquery and four inputs (year, month, day, hidden for the whole date) - not neat.
However, I can't quite make the one that you provided work with my code.
Controller:
Code:
...
var $fields = array(
'data_ur' => array('name' => 'data_ur'),
);
function add()
{
$data = $this->fields;
$this->validation->set_rules($this->rules);
if ($this->validation->run() == FALSE)
{
foreach($this->fields AS $key => $value)
{
$data[$key]['value'] = $this->input->post($key);
}
$this->response['content'] = $this->load->view('admin/'.$this->dzial_views.'/add', $data, True);
}
else
{
$this->load->model('Zawodnik');
$this->Zawodnik->add(array('data_ur' => $this->input->post('data_ur')));
$this->response['content'] = '<div class="ok">Dodano '.$this->dzial_pojedyncza.'!</div>';
$this->Logs->add($this->dzial, 'dodano (id:'.$this->db->insert_id().')');
}
$this->load->view('admin/index', $this->response);
}
...
View:
Code:
<?php echo form_open(uri_string()); ?>
<table width="90%" border="0" cellspacing="3" cellpadding="3">
<tr><td width="180"><b>Data ur</b></td><td><?php echo form_date($data_ur); ?></td></tr>
<tr><td> </td><td><?php echo form_submit('submit', 'Dodaj'); ?></td></tr>
</table>
<?php echo form_close(); ?>
<div class="not_ok"><?=$this->validation->error_string; ?></div>
Changes to your function:
Code:
if (isset($name))
{
$selected = $name;
}
INSTEAD OF:
if (isset($_POST[$name]))
{
$selected = $_POST[$name];
}
I think that it has to be something with the arrays provided to the function, but I can't quite figure it out :/