This topic contains a post which is marked as Best Answer. Press here if you would like to see it.
*

mwindey

  • *****
  • 475 posts
Make transaction field required possible?
« on: June 12, 2022, 06:30:16 PM »
I am looking for a way to make the transaction and condition field required.... Can this be done in Epsilon?
Not sure if it was possible to do it in other themes but i was thinking about it to make it required.

Thanks

« Last Edit: June 12, 2022, 06:33:49 PM by mwindey »

*

MB Themes

Re: Make transaction field required possible?
« Reply #1 on: June 13, 2022, 11:55:29 AM »
@mwindey
As in Epsilon those are select boxes, it should not be complicated.
For jQuery Validation, you have already way to do it in item-post.php (i.e. search for catId)

Code: [Select]
catId: {
  required: true,
  digits: true
}

catId: "Choose one category.",

You only need required part.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 475 posts
Re: Make transaction field required possible?
« Reply #2 on: June 13, 2022, 01:34:18 PM »
@MB Themes,

Piece off cake after your clear explanation  8) Thanks again!  :-*

Code: [Select]
sTransaction: {
required: true,
digits: true
},

Code: [Select]
sTransaction: '<?php echo osc_esc_js(__('Transaction: this field is required.''epsilon')); ?>',
« Last Edit: June 13, 2022, 01:38:56 PM by mwindey »

*

MB Themes

Re: Make transaction field required possible?
« Reply #3 on: June 13, 2022, 01:41:49 PM »
@mwindey
This part is redundant:
digits: true
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 475 posts
Re: Make transaction field required possible?
« Reply #4 on: June 13, 2022, 02:09:58 PM »
@MB Themes,

Super! thanks  :-*

Also added:
Code: [Select]
$prepare['i_transaction'] = eps_get_session('sTransaction') <> '' ? eps_get_session('sTransaction') : '';
« Last Edit: June 13, 2022, 02:56:58 PM by mwindey »

*

mwindey

  • *****
  • 475 posts
Re: Make transaction field required possible?
« Reply #5 on: February 08, 2024, 02:07:23 PM »
Let's dust off this topic with the following question  :D In item-post I check whether the transaction field has been filled in. However, if the price field is disabled in the category, this field is also not visible, but it is checked by jQuery Validation and a warning message that the field has not been completed appears. Is there a way that when the price field is inactive the check on transaction field is also disabled? :-\ :-\

*

MB Themes

Re: Make transaction field required possible?
« Reply #6 on: February 08, 2024, 03:02:52 PM »
@mwindey
You have option to disable "extra fields" in selected categories - in theme settings.
  To get fast support, we need following details: Detail description, URL to reproduce problem, Screenshots

*

mwindey

  • *****
  • 475 posts
Re: Make transaction field required possible?
« Reply #7 on: February 08, 2024, 03:47:29 PM »
@MB Themes

I tried that but as you now i did some modifications on item-post earlier.
Code: [Select]
    // Code for form validation
    $("form[name=item]").validate({
      rules: {
       sTransaction: {
         required: true,
        },
And that is the reason why it is checking if the field is correctly answered. When i remove that line it is not mandatory anymore for none of the catgories.. Now i am trying with:

Code: [Select]
<?php 
$excludedCategories 
eps_get_session('catId');
if (!empty(
$excludedCategories)) {
    while (
osc_has_categories()) {
        
$categoryId osc_category_id(); 
        if (
in_array($categoryId$excludedCategories)) {
            continue;
        }
        if (
$categoryId == 8) {
            continue;
        }
        
?>

        sTransaction: {
            required: true,
        },
    <?php ?>
<?php ?>
But it's not working  :(
« Last Edit: February 09, 2024, 10:02:28 AM by mwindey »

Marked as best answer by frosticek on February 09, 2024, 03:24:55 PM
*

mwindey

  • *****
  • 475 posts
Re: Make transaction field required possible?
« Reply #8 on: February 09, 2024, 02:46:46 PM »
Solved in the javascript... When the price field is activated all is shown as is.... When pricefield disabled only transaction and condition fields show and  not mandatory anymore .... me happy  :P
Code: [Select]
    if(cat_id > 0) {
        if(catPriceEnabled[cat_id] == 1) {
            $('.item-publish section.s4').show(0).removeClass('hidden');
            $('.item-publish .status-wrap').fadeIn(200).removeClass('hidden');
            $('.item-publish .transaction-wrap').fadeIn(200).removeClass('hidden');
            $('.item-publish .condition-wrap').fadeIn(200).removeClass('hidden');
            $('.item-publish .selection').fadeIn(200).removeClass('hidden');
            $('.item-publish .in label[for="price"]').show();
            $('.item-publish .in .req').show();

        } else {
            $('.item-publish section.s4').show(0).removeClass('hidden');
            $('#price').val('');
            $('.item-publish section.s4 .or').hide(0).addClass('hidden');
            $('.item-publish .in label[for="price"]').hide();
            $('.item-publish .in .req').hide();
            $('.item-publish .status-wrap').fadeIn(200).removeClass('hidden');
            $('.item-publish .transaction-wrap').fadeIn(200).removeClass('hidden');
            $('.item-publish .condition-wrap').fadeIn(200).removeClass('hidden');
            $('.item-publish .selection').fadeOut(200).removeClass('hidden');
            $("#sTransaction, #sCondition").rules("remove");
        }
« Last Edit: February 09, 2024, 05:45:17 PM by mwindey »