Welcome Guest, Not a member yet? Register   Sign In
Edit blog entry-> validation probs
#1

[eluser]Zimooon[/eluser]
Hey guys,

following problem:

In my Edit Function for my Blog i got following View:

Code:
<?php
    
    $this->db->select('*');
    $this->db->where('id', $this->uri->segment(3));
    $query = $this->db->get('posts');
    foreach ($query->result() as $row)
    {
          $title = $row->title;
          $date = $row->date;
          $content = $row->content;
          $image = $row->image;
          $foldername = $row->foldername;
          $active = $row->active;
    }
    
    ?>    
                              
  <?php $attributes = array('name' => 'createnews');?>  
  <?php echo form_open('crud/update/'.$this->uri->segment(3) , $attributes ); ?>
    
    
    

    
                    
                
    <div style="margin:0 0 20px 0; color:red"> &lt;?php echo validation_errors(); ?&gt;</div>
    <fieldset>
      <label for="title">Titel:</label>
      &lt;input type="text" id="title" name="title" value="&lt;?php echo $title ?&gt;" class="inputText" /&gt;
    </fieldset>
    
    <fieldset>
      <label for="date">Datum:</label>
      &lt;input type="text" id="date" name="date" value="&lt;?php echo unix_to_date($date)?&gt;" class="inputText" /&gt;
    </fieldset>
    
    <fieldset>
      <label for="content">Inhalt:</label>
      &lt;textarea rows="15" cols="80" style="width: 30%" type="text"  class="tinymce" name="content"  class="inputContent"&gt;&lt;?php echo $content ?&gt;&lt;/textarea&gt;
    </fieldset>

Now when i got validation errors it sets everything back to the data from database.
For the validation i use
Code:
&lt;?php echo set_value('title')?&gt;
But how can i tell him to use this when throwing errors.
Use other view ? or is there anything hmm more logical.

best regards
#2

[eluser]Zimooon[/eluser]
my first solution (pretty ugly as i think):
Code:
<fieldset>
      <label for="place">Veranstaltungsort:</label>
      &lt;input type="text" id="place" name="place" value="&lt;?php if(validation_errors() == NULL): ?&gt; &lt;?php echo $place ?&gt; &lt;?php elseif(validation_errors() != NULL): ?&gt; &lt;?php echo set_value('place') ?&gt; &lt;?php endif;?&gt;" class="inputText" /&gt;
    </fieldset>




Theme © iAndrew 2016 - Forum software by © MyBB