Advertisement:

Author Topic: [SOLVED]Adding an Asterix to custom field  (Read 942 times)

LMR

  • Newbie
  • *
  • Posts: 17
[SOLVED]Adding an Asterix to custom field
« on: April 02, 2017, 01:16:13 am »
Hi,

How can i add an asterix character '*' before a custom field in the item-post to let the user know that the field is mandatory?
thank you

BR

« Last Edit: April 05, 2017, 08:03:47 pm by LMR »

Liath

  • issues
  • Hero Member
  • *
  • Posts: 1346
  • </html> the end is always near
Re: Adding an Asterix to custom field
« Reply #1 on: April 02, 2017, 04:53:01 am »
you could do this with simple css

Code: [Select]
.your-element:before{
    content: "*";
}

LMR

  • Newbie
  • *
  • Posts: 17
Re: Adding an Asterix to custom field
« Reply #2 on: April 02, 2017, 09:19:53 pm »
Hi Liath,

Actually what is confusing me, is that i don't know how the Custom Fields are called in the item-post.php, all i can see is 'ItemForm::plugin_edit_item();'and 'ItemForm::plugin_post_item();' even inside the method all i can find is price related issues...
My custom field identifier name is 'room_type_1' so how exactly should i do it, where to put the css and how to call it.

Thanks

anuituanu

  • Jr. Member
  • **
  • Posts: 61
Re: Adding an Asterix to custom field
« Reply #3 on: April 03, 2017, 08:56:41 pm »
i add asterix character like see attachments
maybe it's not best solution.. but work for me...  :-\

LMR

  • Newbie
  • *
  • Posts: 17
Re: Adding an Asterix to custom field
« Reply #4 on: April 03, 2017, 10:23:49 pm »
Hi,

In the beginning I tried like this, but then it also show '*' in the product listing page item.php


anuituanu

  • Jr. Member
  • **
  • Posts: 61
Re: Adding an Asterix to custom field
« Reply #5 on: April 03, 2017, 11:36:11 pm »
i only have 3 customfields.
size,brand,extrainfo

i did like this for item.php
(bender base theme... in this case im using osclasswizards theme)

Code: [Select]
        <div id="custom_fields">
          <?php if( osc_count_item_meta() >= ) { ?>
          <br />
          <div class="meta_list">
            <?php while ( osc_has_item_meta() ) { ?>
            <?php if(osc_item_meta_value()!='') { ?>
            <div class="meta"> <strong><?php echo osc_item_meta_name(); ?>:</strong> <?php echo osc_item_meta_value(); ?> </div>
            <?php ?>
            <?php ?>
          </div>
          <?php ?>
        </div>

Replace with :
Code: [Select]
        <div id="custom_fields">
<div class="meta_list">
<?php $custom_field = array();
if( osc_count_item_meta() >= ) { 
                    while ( 
osc_has_item_meta() ) { 
                        if(
osc_item_meta_value() !="") {
            
$custom_field_name[osc_item_meta_slug()] = osc_item_meta_name();
            
$custom_field_value[osc_item_meta_slug()] = osc_item_meta_value();
                        }
                    }
?>
                     
 <?php
if ($custom_field_value['dim-size']) { ?>

    <p class="left"><strong><?php _e('Size'OSCLASSWIZARDS_THEME_FOLDER); ?> :</strong><br><?php echo $custom_field_value['dim-size'] ;?></p>
<?php ?>
 <?php
if ($custom_field_value['brand']) { ?>

    <p class="left"><strong><?php _e('Brand'OSCLASSWIZARDS_THEME_FOLDER); ?> :</strong><br><?php echo $custom_field_value['brand'] ;?></p>
<?php ?>
 <?php
if ($custom_field_value['info']) { ?>

    <p class="left"><strong><?php _e('Extra Info'OSCLASSWIZARDS_THEME_FOLDER); ?> :</strong><br><?php echo $custom_field_value['info'] ;?></p>
<?php ?>
</div>
         </div>

PS :
need add all custom filed in to like this :   
Code: [Select]
<?php
if ($custom_field_value['YOUR-IDENTIFIER-NAME']) { ?>

    <p class="left"><strong><?php _e('YOUR CUSTOM FILEDS NAME'OSCLASSWIZARDS_THEME_FOLDER); ?> :</strong><br><?php echo $custom_field_value['YOUR-IDENTIFIER-NAME'] ;?></p>
<?php ?>

sure.. just update po and mo file for multi language site.
« Last Edit: April 03, 2017, 11:52:02 pm by anuituanu »

LMR

  • Newbie
  • *
  • Posts: 17
Re: Adding an Asterix to custom field
« Reply #6 on: April 04, 2017, 10:02:55 pm »
Hi,

What u posted is for item.php so this is for styling in the details page of a product, what i need is in the post-item.php so i can let the user knows that this custom field is required!
Thanks

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Adding an Asterix to custom field
« Reply #7 on: April 05, 2017, 12:45:28 am »
Hi,

Add this rule to your theme main style sheet (main.css, style.css... that depends on the theme):

Code: [Select]
    #div_meta_room_type_1 label:before {
        content: "*";
    }

Regards

LMR

  • Newbie
  • *
  • Posts: 17
Re: Adding an Asterix to custom field
« Reply #8 on: April 05, 2017, 02:47:10 pm »
Hi teseo,

Whenever I use label::before or label:after and try to use content it's not taking any effect for ex: label:after[for=meta_room_type_1] {content: "*";color: red;}
Actually what is working for me is something like this when i use only label without before and after and content:
label[for=meta_room_type_1] {color: red;}

Thanks

Liath

  • issues
  • Hero Member
  • *
  • Posts: 1346
  • </html> the end is always near
Re: Adding an Asterix to custom field
« Reply #9 on: April 05, 2017, 06:14:37 pm »
Hi,

Add this rule to your theme main style sheet (main.css, style.css... that depends on the theme):

Code: [Select]
    #div_meta_room_type_1 label:before {
        content: "*";
    }

Regards



you could try to add an !important...
Code: [Select]
   
#div_meta_room_type_1 label:before {   
    content: "*" !important;   
}

teseo

  • Hero Member
  • *****
  • Posts: 6169
Re: Adding an Asterix to custom field
« Reply #10 on: April 05, 2017, 06:20:53 pm »
This should work for what you want:

Code: [Select]
    label[for=meta_room_type_1] {
        color: red;
    }
    label[for=meta_room_type_1]:before {
        content: "*";
    }

Regards

Regards

LMR

  • Newbie
  • *
  • Posts: 17
Re: Adding an Asterix to custom field
« Reply #11 on: April 05, 2017, 06:56:30 pm »
Great teseo, it's working this way!
Thanks

moinuddin

  • Full Member
  • ***
  • Posts: 102
Re: Adding an Asterix to custom field
« Reply #12 on: June 11, 2019, 11:19:53 am »
This should work for what you want:

Code: [Select]
    label[for=meta_room_type_1] {
        color: red;
    }
    label[for=meta_room_type_1]:before {
        content: "*";
    }

Regards

Regards



hi teseo i tried this in my bender theme ..but it didnt worked..it didnt show "*" in red ..instead it shows ":" in black..can you help me in solving this ??

thanks in advance