Advertisement:

Author Topic: [Select a Category] Default value in form  (Read 4822 times)

naopercatempo

  • Newbie
  • *
  • Posts: 5
[Select a Category] Default value in form
« on: February 02, 2012, 09:46:16 pm »
Hi folks,

So this is what I need: in my website, customers are complaining to when they are viewing the site inside a category (for ex.: Category # 125), then click on add ad button, then when inserting a new item have the category selected to # 125, not the message saying to select one. Tried really hard to be short and clear!

So, I'll need to create a variable to pass from /index.php?page=search&sCategory=125 to index.php?page=item&action=item_add. Easy, Right?

But, after this variables, I'm stock at <?php ItemForm::category_select(null, null, __('Select a category', 'modern')); ?> inside modern theme's item-post.php file.

Any ideas on how to put a default value on that? What it's those two null variables?

Guess it's a nice implementation to future versions, ah?

trains58554

  • Osclass contributor
  • Hero Member
  • *****
  • Posts: 3642
  • osCanyon, the class of Osclass
Re: [Select a Category] Default value in form
« Reply #1 on: February 02, 2012, 09:53:17 pm »
Hi naopercatempo,

Which theme are you using? I am unable to reproduce this on the modern theme.

Thanks

jay

naopercatempo

  • Newbie
  • *
  • Posts: 5
Re: [Select a Category] Default value in form
« Reply #2 on: February 14, 2012, 10:38:08 am »
Hi,

If we can play with <?php ItemForm::category_select(null, null, __('Select a category', 'modern')); ?> will solve the problem, assuming that we can put some variables inside it, instead of those "null,null" stuff

Any guess?

naopercatempo

  • Newbie
  • *
  • Posts: 5
Re: [Select a Category] Default value in form
« Reply #3 on: February 24, 2012, 04:50:55 pm »
Hi naopercatempo,

Which theme are you using? I am unable to reproduce this on the modern theme.

Thanks

jay

It´s modern theme, at item-post.php

artitmedia.eu

  • Newbie
  • *
  • Posts: 14
Re: [Select a Category] Default value in form
« Reply #4 on: March 20, 2012, 01:00:39 pm »
Hi.
Did anyone find any solution for this issue?
I have the same problem, the Category menu shows the category selected by the last user that posted an item, instead of the default text, 'Select a category'
Please advice, where can it be changed.

Or, why all the fields are filled with the last values from the last added item?

Thanks alot.

Noosa

  • Jr. Member
  • **
  • Posts: 55
Re: [Select a Category] Default value in form
« Reply #5 on: March 20, 2012, 02:24:47 pm »
Hi folks,

So this is what I need: in my website, customers are complaining to when they are viewing the site inside a category (for ex.: Category # 125), then click on add ad button, then when inserting a new item have the category selected to # 125, not the message saying to select one. Tried really hard to be short and clear!

So, I'll need to create a variable to pass from /index.php?page=search&sCategory=125 to index.php?page=item&action=item_add. Easy, Right?

But, after this variables, I'm stock at <?php ItemForm::category_select(null, null, __('Select a category', 'modern')); ?> inside modern theme's item-post.php file.

Any ideas on how to put a default value on that? What it's those two null variables?

Guess it's a nice implementation to future versions, ah?

Check out https://github.com/osclass/OSClass/blob/master/oc-includes/osclass/helpers/hCategories.php

On line 243 or abouts category_select($name, $category, $default_str);

Should get you started in the right direction...

carsangrah123

  • Jr. Member
  • **
  • Posts: 59
  • www.carsangrah.com
Re: [Select a Category] Default value in form
« Reply #6 on: November 29, 2013, 01:56:24 pm »
<?php ItemForm::category_select(null, '2', __('Select a category', 'modern')); ?>
where 2 = category id


Hi folks,

So this is what I need: in my website, customers are complaining to when they are viewing the site inside a category (for ex.: Category # 125), then click on add ad button, then when inserting a new item have the category selected to # 125, not the message saying to select one. Tried really hard to be short and clear!

So, I'll need to create a variable to pass from /index.php?page=search&sCategory=125 to index.php?page=item&action=item_add. Easy, Right?

But, after this variables, I'm stock at <?php ItemForm::category_select(null, null, __('Select a category', 'modern')); ?> inside modern theme's item-post.php file.

Any ideas on how to put a default value on that? What it's those two null variables?

Guess it's a nice implementation to future versions, ah?

Check out https://github.com/osclass/OSClass/blob/master/oc-includes/osclass/helpers/hCategories.php

On line 243 or abouts category_select($name, $category, $default_str);

Should get you started in the right direction...

sharkey

  • Full Member
  • ***
  • Posts: 102
Re: [Select a Category] Default value in form
« Reply #7 on: July 21, 2014, 11:54:30 am »
Above solution did not work for me. But below solution did.

In item-post.php

Change:

   
Code: [Select]
                        <div class="control-group">
                            <label class="control-label" for="select_1"><?php _e('Category''bender'); ?></label>
                            <div class="controls">
                                <?php ItemForm::category_select(nullnull__('Select a category''bender')); ?>
                            </div>
                        </div>
to:

Code: [Select]
<?php /* 

                        <div class="control-group">
                            <label class="control-label" for="select_1"><?php _e('Category', 'bender'); ?>
</label>
                            <div class="controls">
                                <?php ItemForm::category_select(nullnull__('Select a category''bender')); ?>
                            </div>
                        </div>
*/ ?>
                  
And insert below code above where previous code was.
where 2 = category id

Code: [Select]
<input type="hidden" name="catId" id="catId" class="valid" value="2" />
Answer borrowed from thread about making a country default.

http://forums.osclass.org/general-help/select-a-country/
      
Edit:  After re-reading this thread I don't think this is what OP was trying to accomplish but my search for creating a default category led me here
« Last Edit: July 21, 2014, 12:01:35 pm by sharkey »