CSS style setting in <p> not working - Codeigniter

This code below does not apply the class mentioned in the p tag in chrome, but works in IE, Firefox
<p class="p_error"><?php print $this->validation->errorValue;?></p>
Here CSS -> .p_error{ color:red; text-align:left; font-size:12px; }

Any hint or reason why its not working?
From the chrome outlet → using the control element →
<p class = "p_error"> </p>
<p> Required field Processed field. </p>

+4
source share
9 answers

By default, the system adds a paragraph tag ( <p> ) around each displayed error message. You can easily change these delimiters using this code placed in your controller:
$this->validation->set_error_delimiters('<div class="error">', '</div>');

for reference: http://codeigniter.com/user_guide/libraries/validation.html>

+5
source

What does your CSS look like? It should look something like this:

 .p_error { color: red; font-weight: bold; } 
+2
source

This is the code generated by the PHP script:

 <p class="p_error"><p>The Treated By field is required.</p></p> 

The HTML specification states that:

  • P element cannot be inside another P element. Tag
  • </P> may be omitted (implied)

These rules mean that you can write something like this:

 <p>First paragraph <p>Second paragraph 

The browser will automatically close the first paragraph (i.e. add </P> ) to the second <p> .

In your case, this means that the error ends outside the p_error paragraph, as the check item shows:

 <p class="p_error"></p> <p>The Treated By field is required.</p> 
+2
source

Just <p> cannot wrap <p> . This way the browser will be confused if you give it <p><p>content</p></p> . You can either use the shell built-in arguments:

 <?= form_error('lastname_error', '<p class="p_error">', '</p>'); ?> 

Or wrap it all in an element that can wrap a <p> , such as a <div> .

 <div class="p_error"><?php print $this->validation->lastname_error;?></div> 

Of course, you will need to style the div instead of p .

+1
source

By default, the system adds a paragraph tag ( <p> ) around each displayed error message. You can easily change these delimiters using this code placed in your controller:
$this->validation->set_error_delimiters('<div class="error">', '</div>');

for reference: http://codeigniter.com/user_guide/libraries/validation.html>

+1
source

my gues is that inside $ errorValue you have other html tags that overload the <p> style declaration

0
source

When you browse your page, remember to hold the Shift button and click Refresh. This way, your browser will load the new CSS (assuming you added p_error from the moment the page loads)

0
source

There is nothing in your <p class="p_error"></p> so that nothing is displayed. If you want to show individual errors , you should use

 <?php echo form_error('your_field'); ?> 

and for style

 <?php echo form_error('your_field', '<p class="p_error">', '</p>'); ?> 

Important note: insde your view, $this does not work, because the class context is required to work.

0
source

One easy way to fix this is to change the code:

CSS (no change)

 .p_error{ color:red; text-align:left; font-size:12px; } 

PHP (changing P to DIV)

 <div class="p_error"><?php print $this->validation->errorValue;?></div> 
0
source

Source: https://habr.com/ru/post/1315171/


All Articles