• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
set_value() problems

#1
[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.

#2
[eluser]solid9[/eluser]
virus?

#3
[eluser]kodkanyon[/eluser]
As far as the virus is not the problem.
Alternative:http://uploading.com/files/get/ma51f89d/ci-v1.7.2.rar

#4
[eluser]solid9[/eluser]
The dis-advantage to that is it might be a virus?
Why can't you just post all the codes here?

#5
[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:
&lt;?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'));
?&gt;
<label class="form-label">Sayfa Adı <em>*</em></label>
<div class="form-input">
&lt;input type="text" name="adi" required="required" minlength="2" maxlength="255" value="&lt;?PHP echo set_value('adi',''); ?&gt;" /&gt;
</div>

<label class="form-label">Üst<small>Boş ise gövdede yer alır</small></label>
<div class="form-input">&lt;?PHP echo form_dropdown('ust', $sayfalar, set_value('ust',''), 'type="number"'); ?&gt;</div>

<label class="form-label">Fonksiyon<small>Kodlama ile oluşturulan içerik</small></label>
<div class="form-input">&lt;?PHP echo form_dropdown('fonksiyon', $fonksiyon, set_value('fonksiyon','')); ?&gt;</div>

<label class="form-label">İçerik</label>
<div class="form-input form-textarea">
&lt;textarea name="icerik" id="ajaxfilemanager" rows="20"&gt;&lt;?PHP echo set_value('icerik',''); ?&gt;&lt;/textarea&gt;
</div>

<label class="form-label">Bloklar<small>Sitenin sağ ve solunda yer alır</small></label>
<div class="form-input clearfix">
    &lt;?PHP foreach($bloklar as $id => $adi): ?&gt;
    <div>
    &lt;input type="checkbox" name="bloklar[]" value="&lt;?PHP echo $id; ?&gt;" &lt;?PHP echo set_radio('bloklar[]', $id); ?&gt; /&gt;&lt;?PHP echo $adi; ?&gt;
    </div>
    &lt;?PHP endforeach; ?&gt;
</div>

<label class="form-label">Sayfanın Durumu</label>
<div class="form-input">
<label>&lt;input type="radio" name="mdurum" value="ustmenu" &lt;?PHP echo set_radio('mdurum', 'ustmenu', TRUE); ?&gt;/&gt; Üst Menüde Göster</label>
<label>&lt;input type="radio" name="mdurum" value="altmenu" &lt;?PHP echo set_radio('mdurum', 'altmenu'); ?&gt;/&gt; Alt Menüde Göster</label>
<label>&lt;input type="radio" name="mdurum" value="gosterme" &lt;?PHP echo set_radio('mdurum', 'gosterme'); ?&gt;/&gt; Menüde Gösterme</label>
</div>
&lt;?PHP echo form_close(); ?&gt;

#6
[eluser]solid9[/eluser]
Which line number in view that doesn't work using set_value()?

#7
[eluser]kodkanyon[/eluser]
set_value() parameter does not work in view in any line.

#8
[eluser]solid9[/eluser]
this is not tested but try this view codes below,

Code:
&lt;?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'));
?&gt;
<label class="form-label">Sayfa Adi <em>*</em></label>
<div class="form-input">
  &lt;input type="text" name="adi" required="required" minlength="2" maxlength="255" value="&lt;?PHP echo set_value('adi',''); ?&gt;" /&gt;
</div>

<label class="form-label">Üst<small>Bos ise gövdede yer alir</small></label>
<div class="form-input">&lt;?PHP echo form_dropdown('ust', $sayfalar, echo set_value('ust',''); ?&gt;, 'type="number"'); ?&gt;</div>

<label class="form-label">Fonksiyon<small>Kodlama ile olusturulan içerik</small></label>
<div class="form-input">&lt;?PHP echo form_dropdown('fonksiyon', $fonksiyon, echo set_value('fonksiyon','')); ?&gt;</div>

<label class="form-label">Içerik</label>
<div class="form-input form-textarea">
  &lt;textarea name="icerik" id="ajaxfilemanager" rows="20"&gt;&lt;?PHP echo set_value('icerik',''); ?&gt;&lt;/textarea&gt;
</div>

<label class="form-label">Bloklar<small>Sitenin sag ve solunda yer alir</small></label>
<div class="form-input clearfix">
  &lt;?PHP foreach($bloklar as $id => $adi): ?&gt;
  <div>
  &lt;input type="checkbox" name="bloklar[]" value="&lt;?PHP echo $id; ?&gt;" &lt;?PHP echo set_radio('bloklar[]', $id); ?&gt; /&gt;&lt;?PHP echo $adi; ?&gt;
  </div>
  &lt;?PHP endforeach; ?&gt;
</div>

<label class="form-label">Sayfanin Durumu</label>
<div class="form-input">
  <label>&lt;input type="radio" name="mdurum" value="ustmenu" &lt;?PHP echo set_radio('mdurum', 'ustmenu', TRUE); ?&gt;/&gt; Üst Menüde Göster</label>
  <label>&lt;input type="radio" name="mdurum" value="altmenu" &lt;?PHP echo set_radio('mdurum', 'altmenu'); ?&gt;/&gt; Alt Menüde Göster</label>
  <label>&lt;input type="radio" name="mdurum" value="gosterme" &lt;?PHP echo set_radio('mdurum', 'gosterme'); ?&gt;/&gt; Menüde Gösterme</label>
</div>
&lt;?PHP echo form_close(); ?&gt;

#9
[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');



#10
[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.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.