How To Disable A Mandatory Field from Being MANDATORY

  • Jason
    Jason
    Titan
     
    654 points

    Hi Guys’n Gals

    May I ask a little help here pls..

    I’d like to know how to stop the DESCRIPTION in Directory Theme section from being Mandatory field, otherwise hiding the DESCRIPTION section wont work, how to stop from being MANDATORY ?

    Pic attached for no confusion to my question

    Attachments:
    You must be logged in to view attached files.

    Jason
    Jason
    Titan
     
    654 points

    Thanks in advance


    Josh
    Josh
    Super Guru
     
    13,886 points

    Hello Jason,
    Please access the file Appearance >add-form.php remove below code


    if(de3.value == ''){
    alert('<?php echo $CORE->_e(array('validate','0')); ?>');
    de3.style.border = 'thin solid red';
    de3.focus();
    colAll(); jQuery('.stepblock2').collapse('show');
    return false;
    }


    Jason
    Jason
    Titan
     
    654 points

    I have noticed that this actually disables MANDATORY fields sitewide not just the DESCRIPTION section, is that what it does disables every mandatory field, was just hoping the description only ?


    Josh
    Josh
    Super Guru
     
    13,886 points

    Hello Jason,
    Which other fields are getting affected?Seems ok on my end


    Jason
    Jason
    Titan
     
    654 points

    I hues what i want, is for certain fields to appear as the the TITLE. I know i add them in page setup, but when completing the form it demands I enter into the TITLE section, I dont want that



    Janak
    Super Guru
     
    1,179 points

    Hi Jason

    Have you tried setting Min. Description Length to 0 in Listing Setup Options?


    Jason
    Jason
    Titan
     
    654 points

    Its the TITLE, I already dealt with Description while ago, thanks Janak



    Janak
    Super Guru
     
    1,179 points

    I’m not sure why you would want to allow a blank Title but you can probably do it by making a small mod in each of add-form.php and tpl-add.php, You can then place the modified copies in your child theme. I’ve not tested it though.

    If you need any help with this let me know.


    Jason
    Jason
    Titan
     
    654 points

    This is all I want to happen, as remove the completion of the ORIGINAL TITLE so my own CUSTOM FIELDS can become the TITLE

    This becomes the TITLE instead

    http://prntscr.com/h99oj0

    http://prntscr.com/h99qcx



    Julian
    Newbie
     
    90 points

    thats kinda cool what ya want…please post if ya get the answer..I may use that in future..I remember I was usingg some code awhile back that manipulated the titles and stuff I wish I could remember for you…i had it saved in note pad but computer had to be formatted so lost it all arrggg…but please do post if ya get answer..I think that’s brilliant!



    Janak
    Super Guru
     
    1,179 points

    You could try:

    In add-form.php

    Comment out required line in following code

    $field = array();
    $field[$o]['title'] = $CORE->_e(array('add','10'));
    $field[$o]['name'] = "post_title";
    $field[$o]['type'] = "text";
    $field[$o]['class'] = "form-control";
    // $field[$o]['required'] = true;
    $field[$o]['ontop'] = true;
    $field[$o]['placeholder'] = hook_add_post_title_text("");

    Add return true; in following code

    // LISTING DESCRIPTION VALIDATION
    var de1 = document.getElementById("form_post_title");
    return true;
    if(de1.value == ''){
    alert('<?php echo $CORE->_e(array('validate','0')); ?>');
    de1.style.border = 'thin solid red';
    de1.focus();
    colAll(); jQuery('.stepblock2').collapse('show');
    return false;
    }

    In tpl-add. find following code and change 2 to 0;

    // VALIDATION
    if(strlen($_POST['form']['post_title']) < 2){
    $GLOBALS['error_message'] = $CORE->_e(array('add','23'));

    It seems to work but I haven’t tested any implications in the system so no guarantees. You could remove Title completely from add-form.php.


    Jason
    Jason
    Titan
     
    654 points

    OK,,,,,,,,,,,,

    This is what I done, all worked, but it removed the javascript piece that i really liked

    Here below are 5 images on what I done.

    All worked, except like I said, removed something I like in image 1.

    Image 1: http://prntscr.com/h9ndng

    Image 2: http://prntscr.com/h9ne0p

    Image 3: http://prntscr.com/h9ne5r

    Image 4: http://prntscr.com/h9neg4

    Image 5: http://prntscr.com/h9nggm

    Low and behold, all seems like a great idea, can work in some sites thene again some sites might need the TITLE to be used. In my case dont need title.

    Hope this also helps you all out, and thanks for the heads up in playing with the php files

    Test these out yrselves on a dummy site


    Josh
    Josh
    Super Guru
     
    13,886 points

    Thanks for sharing Jason :)



    Julian
    Newbie
     
    90 points

    awesome!! Thanks Jason


Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.