[eluser]kodkanyon[/eluser]
Previously i was using set_value() function without problems, but recently i am having problems. In controllers, when i try set_value(name) i can see the value that returns but it does not work in view.
I simplified my codes as much as possible and here is the link.
http://www.prosel.com.tr/ci-v1.7.2.rar
I would be happy if you can help.
[eluser]solid9[/eluser]
virus?
[eluser]kodkanyon[/eluser]
As far as the virus is not the problem.
Alternative:http://uploading.com/files/get/ma51f89d/ci-v1.7.2.rar
[eluser]solid9[/eluser]
The dis-advantage to that is it might be a virus?
Why can't you just post all the codes here?
[eluser]kodkanyon[/eluser]
config/autoload.php
Code: $autoload['libraries'] = array('database','session','form_validation','mesaj','kontrol');
$autoload['helper'] = array('url','security','html','form');
controllers/sayfalar.php
Code: <?PHP if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Sayfalar extends Controller {
function Sayfalar() {
parent::Controller();
}
function kaydet(){
$form_kural = array(
array('field' => 'adi', 'label' => 'Sayfa Adı', 'rules' => 'trim|required|min_length[2]|max_length[255]|escape_str'),
array('field' => 'baslik', 'label' => 'Başlık', 'rules' => ''),
array('field' => 'bloklar[]', 'label' => 'Bloklar', 'rules' => ''),
array('field' => 'gosterim', 'label' => 'Gösterim', 'rules' => ''),
array('field' => 'mdurum', 'label' => 'Sayfanın Durumu', 'rules' => ''),
array('field' => 'url', 'label' => 'Url', 'rules' => 'trim|required|min_length[2]|max_length[255]|escape_str')
);
$this->form_validation->set_rules($form_kural);
if ($this->form_validation->run() == FALSE)
{
$this->session->set_flashdata('error', $this->form_validation->_error_array);
redirect('/ekle','refresh');
}else{
$data = array(
'adi' => trim($this->input->post('adi')),
'baslik' => trim($this->input->post('baslik')),
'ust' => $this->input->post('ust'),
'fonksiyon' => $this->input->post('fonksiyon'),
'icerik' => $this->input->post('icerik'),
'dil' => $this->session->userdata('dil'),
'mdurum' => $this->input->post('mdurum'),
'url' => url_title($this->input->post('url')),
'title' => $this->input->post('title'),
'metakey' => $this->input->post('metakey'),
'metadesc' => $this->input->post('metadesc'),
'etiketbulutu' => $this->input->post('etiketbulutu'),
'kaydeden_kullanici' => $this->session->userdata('kadi')
);
$sonuc = $this->MGenel->add('sayfalar',$data);
if($sonuc == TRUE):
$this->session->set_flashdata('success','Sayfa başarıyla oluşturuldu.');
redirect('/ekle','refresh');
elseif($sonuc == FALSE):
$this->session->set_flashdata('error','Bir sebepten dolayı kayıt gerçekleştirilemedi!');
redirect('/ekle','refresh');
endif;
}
}
}
helpers/MY_form_helper.php
Code: if ( ! function_exists('set_value'))
{
function set_value($field = '', $default = '')
{
$OBJ =& _get_validation_object();
if ($OBJ === TRUE && isset($OBJ->_field_data[$field]))
{
return form_prep($OBJ->set_value($field, $default));
} else {
if ( ! isset($_POST[$field]))
{
return $default;
}
return form_prep($_POST[$field]);
}
}
}
libraries/mesaj.php
Code: class Mesaj {
var $ci;
function Mesaj()
{
$this->ci = & get_instance();
}
function error_view()
{
if(is_array($this->ci->session->flashdata('error')))
{
$text = '<div class="message error"><h3>Error!</h3>';
foreach($this->ci->session->flashdata('error') as $row):
$text .= '<p>'.$row.'</p>';
endforeach;
$text .= '</div>';
return $text;
}
else if($this->ci->session->flashdata('error'))
{
$text = '<div class="message error"><h3>Error!</h3><p>'.$this->ci->session->flashdata('error').'</p></div>';
return $text;
}
}
}
views/ekle.php
Code: <?PHP
if( $this->mesaj->error_view() ): echo $this->mesaj->error_view(); else: echo $this->mesaj->success_view(); endif;
echo form_open('sayfalar/kaydet', array ('class' => 'form has-validation'));
?>
<label class="form-label">Sayfa Adı <em>*</em></label>
<div class="form-input">
<input type="text" name="adi" required="required" minlength="2" maxlength="255" value="<?PHP echo set_value('adi',''); ?>" />
</div>
<label class="form-label">Üst<small>Boş ise gövdede yer alır</small></label>
<div class="form-input"><?PHP echo form_dropdown('ust', $sayfalar, set_value('ust',''), 'type="number"'); ?></div>
<label class="form-label">Fonksiyon<small>Kodlama ile oluşturulan içerik</small></label>
<div class="form-input"><?PHP echo form_dropdown('fonksiyon', $fonksiyon, set_value('fonksiyon','')); ?></div>
<label class="form-label">İçerik</label>
<div class="form-input form-textarea">
<textarea name="icerik" id="ajaxfilemanager" rows="20"><?PHP echo set_value('icerik',''); ?></textarea>
</div>
<label class="form-label">Bloklar<small>Sitenin sağ ve solunda yer alır</small></label>
<div class="form-input clearfix">
<?PHP foreach($bloklar as $id => $adi): ?>
<div>
<input type="checkbox" name="bloklar[]" value="<?PHP echo $id; ?>" <?PHP echo set_radio('bloklar[]', $id); ?> /><?PHP echo $adi; ?>
</div>
<?PHP endforeach; ?>
</div>
<label class="form-label">Sayfanın Durumu</label>
<div class="form-input">
<label><input type="radio" name="mdurum" value="ustmenu" <?PHP echo set_radio('mdurum', 'ustmenu', TRUE); ?>/> Üst Menüde Göster</label>
<label><input type="radio" name="mdurum" value="altmenu" <?PHP echo set_radio('mdurum', 'altmenu'); ?>/> Alt Menüde Göster</label>
<label><input type="radio" name="mdurum" value="gosterme" <?PHP echo set_radio('mdurum', 'gosterme'); ?>/> Menüde Gösterme</label>
</div>
<?PHP echo form_close(); ?>
[eluser]solid9[/eluser]
Which line number in view that doesn't work using set_value()?
[eluser]kodkanyon[/eluser]
set_value() parameter does not work in view in any line.
[eluser]solid9[/eluser]
this is not tested but try this view codes below,
Code: <?PHP
if( $this->mesaj->error_view() ): echo $this->mesaj->error_view(); else: echo $this->mesaj->success_view(); endif;
echo form_open('sayfalar/kaydet', array ('class' => 'form has-validation'));
?>
<label class="form-label">Sayfa Adi <em>*</em></label>
<div class="form-input">
<input type="text" name="adi" required="required" minlength="2" maxlength="255" value="<?PHP echo set_value('adi',''); ?>" />
</div>
<label class="form-label">Üst<small>Bos ise gövdede yer alir</small></label>
<div class="form-input"><?PHP echo form_dropdown('ust', $sayfalar, echo set_value('ust',''); ?>, 'type="number"'); ?></div>
<label class="form-label">Fonksiyon<small>Kodlama ile olusturulan içerik</small></label>
<div class="form-input"><?PHP echo form_dropdown('fonksiyon', $fonksiyon, echo set_value('fonksiyon','')); ?></div>
<label class="form-label">Içerik</label>
<div class="form-input form-textarea">
<textarea name="icerik" id="ajaxfilemanager" rows="20"><?PHP echo set_value('icerik',''); ?></textarea>
</div>
<label class="form-label">Bloklar<small>Sitenin sag ve solunda yer alir</small></label>
<div class="form-input clearfix">
<?PHP foreach($bloklar as $id => $adi): ?>
<div>
<input type="checkbox" name="bloklar[]" value="<?PHP echo $id; ?>" <?PHP echo set_radio('bloklar[]', $id); ?> /><?PHP echo $adi; ?>
</div>
<?PHP endforeach; ?>
</div>
<label class="form-label">Sayfanin Durumu</label>
<div class="form-input">
<label><input type="radio" name="mdurum" value="ustmenu" <?PHP echo set_radio('mdurum', 'ustmenu', TRUE); ?>/> Üst Menüde Göster</label>
<label><input type="radio" name="mdurum" value="altmenu" <?PHP echo set_radio('mdurum', 'altmenu'); ?>/> Alt Menüde Göster</label>
<label><input type="radio" name="mdurum" value="gosterme" <?PHP echo set_radio('mdurum', 'gosterme'); ?>/> Menüde Gösterme</label>
</div>
<?PHP echo form_close(); ?>
[eluser]solid9[/eluser]
nevermind my codes above I'm sure it's error,
but try to review the manual,
http://ellislab.com/codeigniter/user-gui...elper.html
for dropdown you don't need to use set_value() it has it's own.
example:
Code: $options = array(
'small' => 'Small Shirt',
'med' => 'Medium Shirt',
'large' => 'Large Shirt',
'xlarge' => 'Extra Large Shirt',
);
$shirts_on_sale = array('small', 'large');
echo form_dropdown('shirts', $options, 'large');
[eluser]solid9[/eluser]
The same with form_textarea() it has built it set value so you don't need to use set_value().
Code: $data = array(
'name' => 'icerik',
'id' => 'ajaxfilemanager',
'rows' => '20',
'value' => 'hello',
);
echo form_textarea($data);
I hope this helped you.
|