Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Make standard fields required

  1. #1
    imrankha is offline Senior Member
    Join Date
    Jul 2008
    Posts
    40

    Default Make standard fields required

    Hi all,
    I have looked and looked and tried to make standard fields required, looked at every wiki or tutorial and they seem not to work with my Sugar 5.2 PRO installation.
    Can anyone please help me as to how to make a standard field required in sugar.
    Thank a lot.

  2. #2
    jmertic is offline Sugar Community Manager
    Join Date
    Dec 2007
    Posts
    2,224

    Default Re: Make standard fields required

    Make sure you 'Clear Template Data Cache' and 'Clear Vardefs Data Cache' from the Admin->Repair screen after making any vardef changes.

  3. #3
    letrium is offline Sugar Community Member
    Join Date
    Dec 2008
    Posts
    614

    Default Re: Make standard fields required

    Hi!

    You must to edit 'editviewdefs.php' and add display parameter "require" for needed fields.

    Wait some minutes i'll post an example.

  4. #4
    letrium is offline Sugar Community Member
    Join Date
    Dec 2008
    Posts
    614

    Default Re: Make standard fields required

    Hi!

    Something like this:

    array(array('name'=>'YOUR_FIELD_NAME', 'displayParams'=>array('required'=>true)) ),

  5. #5
    imrankha is offline Senior Member
    Join Date
    Jul 2008
    Posts
    40

    Default Re: Make standard fields required

    hmmm tried that, and didnt work. It will save when the field is empty. Even the red asterisk did not appear. I did the repair and rebuild,cleared the template data cache etc and tried again and still the empty fields save fine??

  6. #6
    imrankha is offline Senior Member
    Join Date
    Jul 2008
    Posts
    40

    Default Re: Make standard fields required

    I just needed to make fields like website,etc required but cant yet. Would appreciate any help. Thanks

  7. #7
    letrium is offline Sugar Community Member
    Join Date
    Dec 2008
    Posts
    614

  8. #8
    dindara is offline Member
    Join Date
    Jan 2009
    Posts
    11

    Default Re: Make standard fields required

    Hi Imrankha,

    If you want to create a new required field, you can do it from
    "Admin -> Studio -> <module_name> -> Fields -> "Add New Fields" -> check on "Required Field" button -> save"

    If you want to change an existing field from "not required" to "required":
    1. Go to 'modules\Project\vardefs.php'
    2. Look for the field you want to change, if you find ''required' => false,", change it to
    "'required' => true,", but if don't find any "'required' => false," line, then add "'required' => true,".
    For example, if I want to make "Description" field in "Project" module to become "required" field:
    1. Open 'modules\Project\vardefs.php'
    2. Change:
    Code:
    		'description' => array(
    			'name' => 'description',
    			'vname' => 'LBL_DESCRIPTION',
    			'required' => false,   <<<<<<< Change this to "true"
    			'type' => 'text',
    			'comment' => 'Project description'
    		),
    to

    Code:
    		'description' => array(
    			'name' => 'description',
    			'vname' => 'LBL_DESCRIPTION',
    			'required' => true,
    			'type' => 'text',
    			'comment' => 'Project description'
    		),
    3. Admin -> Quick Repair and Rebuild
    And there you go, you have yourself a new "required" field.

  9. #9
    letrium is offline Sugar Community Member
    Join Date
    Dec 2008
    Posts
    614

    Default Re: Make standard fields required

    Hi,dindara!

    AS i understood the question was for fields that not defined in vardefs.

    And what to do for 'assigned_user_name' field?

  10. #10
    dindara is offline Member
    Join Date
    Jan 2009
    Posts
    11

    Default Re: Make standard fields required

    Hi Letrium,

    Please corret me if I'm wrong, but I don't see the original post mentioned something about for "fields that not defined in vardefs".
    Anyway, you are correct, my previous post was not complete, I left two points behind (I copied it from my manual book I created for my engineers), below are the two points I left behind previously.

    If the field you want to change is not in vardefs.php, please make sure whether or not your module had been changed, since the location of the file you will work on are different. Then follow the steps below,

    A. CUSTOMIZED MODULE
    1. Open 'custom\modules\<module_name>\metadata\editviewdef s.php
    2. Look for the field you want to change, insert " 'displayParams'=>array('required'=>true), "
    For example:
    If you want to change "Refered By" field in "Leads" module, go to 'custom\modules\<module_name>\metadata\editviewdef s.php'
    Look for 'refered_by' field, you would see:
    Code:
    		array (
    		  'name' => 'refered_by',
    		  'label' => 'LBL_REFERED_BY',
    		),
    insert " 'displayParams'=>array('required'=>true), "

    Code:
    		array (
    		  'name' => 'refered_by',
    		  'displayParams'=>array('required'=>true)
    		  'label' => 'LBL_REFERED_BY',
    		),
    3. Admin -> Quick Repair and Rebuild
    And there you go, you have yourself a new "required" field.


    B. UNCUSTOMIZED MODULE
    If the field you want to change is not in vardef.php, and you haven't modified/customized the outlook of the module you want to change, you won't have 'custom\modules\<module_name>' directory. Then you need to change the original editviewdefs.php file located in 'modules\<module_name>\metadata'.
    1. Open 'modules\<module_name>\metadata\editviewdefs.php
    2. Look for the field you want to change, change the code with " array('name'=>'field_name', 'displayParams'=>array('required'=>true))),"
    For example:
    If you want to change "Office Phone" field in the unmodified "Contacts" module, go to 'modules\Contacts\metadata\editviewdefs.php'
    Look for 'phone_work' field, you would see:
    Code:
    array (
        array (
          'name' => 'first_name',
          'customCode' => '{html_options name="salutation" options=$fields.salutation.options selected=$fields.salutation.value}&nbsp;<input name="first_name" size="25" maxlength="25" type="text" value="{$fields.first_name.value}">',
        ),
        'phone_work',
    ),
    Change it to:

    Code:
    array (
        array (
          'name' => 'first_name',
          'customCode' => '{html_options name="salutation" options=$fields.salutation.options selected=$fields.salutation.value}&nbsp;<input name="first_name" size="25" maxlength="25" type="text" value="{$fields.first_name.value}">',
        ),
       array('name'=>'phone_work', 'displayParams'=>array('required'=>true)),
    ),
    3. Admin -> Quick Repair and Rebuild
    And there you go, you have yourself a new "required" field.


    Thanks for reminding me Letrium, otherwise my first post would probably add more headache to Imrankha...

    Imrankha, good luck

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to make a field NOT required
    By kinshibuya in forum Help
    Replies: 9
    Last Post: 2010-12-30, 03:11 PM
  2. standard fields - need to make it required on the UI.
    By rtetlow in forum General Discussion
    Replies: 7
    Last Post: 2008-10-05, 11:14 PM
  3. make relational fields required
    By danrweki in forum Developer Help
    Replies: 2
    Last Post: 2008-08-18, 02:42 PM
  4. Replies: 6
    Last Post: 2008-01-18, 08:50 PM
  5. Replies: 0
    Last Post: 2007-12-27, 09:46 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •