Author Topic: Need Text Input Custom Field to be Required  (Read 2116 times)

catondesigngroup

  • Beginner
  • *
  • Posts: 2
    • Caton Design Group, Web Design and Branding near Pittsburgh PA
Need Text Input Custom Field to be Required
« on: January 24, 2016, 08:16:14 am »
I've searched all over, and bought a couple plugins (rather not badmouth them) but I have yet to find a plugin that works which will make a text input field required.  Radio buttons, select list, yes I am able to make them required with Custom Fields For All.  But not text input.  Help?  There's got to be a (working) plugin out there for this, right?
Seth W. Caton
Vice President
Caton Design Group

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2333
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Need Text Input Custom Field to be Required
« Reply #1 on: January 25, 2016, 09:48:52 am »
When you use the plugin provided by the core team, you can add this function

Code: [Select]
// this not permit to change value !
public function plgVmOnAddToCartFilter($product, $customfield, $customProductData, $customFiltered){
if ($customfield->custom_element !==$this->_name) return ;
if(empty($customProductData[$customfield->virtuemart_custom_id])) {
echo json_encode(array('stat' =>1, 'msg' => "You removed  the text input option")); jexit();
} else if(empty($customProductData[$customfield->virtuemart_custom_id][$customfield->virtuemart_customfield_id])) return ;
$selected = $customProductData[$customfield->virtuemart_custom_id][$customfield->virtuemart_customfield_id];
if( !$selected['comment'] ) {
echo json_encode(array('stat' =>1, 'msg' => "Please fell the text-input !"));
jexit();
}
}
If you dont use the modal popup, then this not work perfectly,you need to add a Joomla redirect.

hisslink

  • Beginner
  • *
  • Posts: 11
Re: Need Text Input Custom Field to be Required
« Reply #2 on: February 12, 2016, 14:55:55 pm »
Thank you very much! Works perfectly for the textinput. I'm also using Custom Fields for All for all the other (required) custom fields. Also bought a plugin to make the textinput fields required, but this didn't work.

servlet

  • Jr. Member
  • **
  • Posts: 331
  • Business optimization
    • Фототапети
  • VirtueMart Version: 3.2.2
Re: Need Text Input Custom Field to be Required
« Reply #3 on: April 05, 2016, 13:19:24 pm »
Where to input this code?
Thank you
I am using: Joomla 3.7.2 VM 3.2.2
Он-лайн магазин за фототапети http://mishelfoster.com

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2333
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 & 3.0.x.y
Re: Need Text Input Custom Field to be Required
« Reply #4 on: April 05, 2016, 22:33:48 pm »
@servlet : In the virtuemart text input plugin class
file : YOURJOOMLASITE\plugins\vmcustom\textinput\textinput.php
inside class plgVmCustomTextinput extends vmCustomPlugin {
Best at end before } closing tag

servlet

  • Jr. Member
  • **
  • Posts: 331
  • Business optimization
    • Фототапети
  • VirtueMart Version: 3.2.2
Re: Need Text Input Custom Field to be Required
« Reply #5 on: April 06, 2016, 07:40:06 am »
thank you
I will try
I am using: Joomla 3.7.2 VM 3.2.2
Он-лайн магазин за фототапети http://mishelfoster.com

doc_denis

  • Beginner
  • *
  • Posts: 29
Re: Need Text Input Custom Field to be Required
« Reply #6 on: September 28, 2016, 19:48:41 pm »
Merci monsieur ;)
ça fonctionne très bien, super pratique le petit message en pop-up.
reste à ajouter une liaison avec le fichier le langue pour le multilingue.
Merci
c'est un truc à ajouter dans un autre lieu, non?

aftertaf

  • Jr. Member
  • **
  • Posts: 140
    • sO couture
  • VirtueMart Version: 3.2.4
Re: Need Text Input Custom Field to be Required
« Reply #7 on: January 22, 2017, 18:02:37 pm »
i need this too for selling gift certificates that are sent by mail.

1- is there a safe way to use this as an override in the template ? In case VM updaes I wouldn't want to lose it.
2- Can the text be replaced by language overrides (i'd be needing it for multilingual site), like i see in other php files ? e.g. <?php echo vmText::_ ('COM_VIRTUEMART_NEED_MAIL_ADDRESS')?>


I confirm that the change works fine, as long as you paste it in the right part of the .php file :)
Webmaster for my wife
Long live joomla, virtuemart and open source in general.
usually latest version of VM & J!
Using POSForWebshops, TemplatecreatorCK, MaximenuCK, VM BatchEdit Pro among other things...
VM 3.2.4, PHP Version 7.0.18-1~dotdeb+8.1, mariadb 10.1.22 Joomla! 3.8.1

mhuebler

  • Beginner
  • *
  • Posts: 47
    • joomla support
  • VirtueMart Version: 3.2
Re: Need Text Input Custom Field to be Required
« Reply #8 on: May 03, 2017, 19:55:32 pm »
Is there someone can help to make this work with template override ?

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2333
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: Need Text Input Custom Field to be Required
« Reply #9 on: May 04, 2017, 02:33:46 am »
You have all explains here. For Joomla overrides, Google is your friend ;)
If you need a developer, contact me or any other developer in the forum for a custom work.

servlet

  • Jr. Member
  • **
  • Posts: 331
  • Business optimization
    • Фототапети
  • VirtueMart Version: 3.2.2
Re: Need Text Input Custom Field to be Required
« Reply #10 on: October 28, 2017, 07:54:11 am »
It works, but fancy box is so small. It is different from other like add to cart and ask a question
Please give mi a hint how to change this fancy box, which file.
I am using: Joomla 3.7.2 VM 3.2.2
Он-лайн магазин за фототапети http://mishelfoster.com

Studio 42

  • Contributing Developer
  • Full Member
  • *
  • Posts: 2333
  • Joomla & Virtuemart addon developper
    • Studio 42 - Virtuemart & Joomla extentions
  • VirtueMart Version: 2.6 &amp; 3.0.x.y
Re: Need Text Input Custom Field to be Required
« Reply #11 on: October 28, 2017, 13:48:07 pm »
If you modify the text and adding a <DIV> or add inline style.
I think it can be solved with some CSS rules

servlet

  • Jr. Member
  • **
  • Posts: 331
  • Business optimization
    • Фототапети
  • VirtueMart Version: 3.2.2
Re: Need Text Input Custom Field to be Required
« Reply #12 on: October 28, 2017, 16:44:40 pm »
Thank you
I will try
I am using: Joomla 3.7.2 VM 3.2.2
Он-лайн магазин за фототапети http://mishelfoster.com

aftertaf

  • Jr. Member
  • **
  • Posts: 140
    • sO couture
  • VirtueMart Version: 3.2.4
Re: Need Text Input Custom Field to be Required
« Reply #13 on: October 29, 2017, 21:43:49 pm »
Hi,

I haven't made any changes that I remember on this setup. It was working before.
Now I get the ajax popup 'you removed the text input option' but like i said, i dont think i modified this custom field since it was setup and tested working (with mandatory typing of data in it)
Any Idea what could be amiss?
 this is obviously being triggered but i cant figure out why...

Code: [Select]
if(empty($customProductData[$customfield->virtuemart_custom_id])) {
echo json_encode(array('stat' =>1, 'msg' => "You removed  the text input option")); jexit();
Webmaster for my wife
Long live joomla, virtuemart and open source in general.
usually latest version of VM & J!
Using POSForWebshops, TemplatecreatorCK, MaximenuCK, VM BatchEdit Pro among other things...
VM 3.2.4, PHP Version 7.0.18-1~dotdeb+8.1, mariadb 10.1.22 Joomla! 3.8.1