Changeset 852

Show
Ignore:
Timestamp:
12/07/06 04:03:24 (2 years ago)
Author:
gboggs
Message:

Throw (JS alert() and CMS errtrans()) errors if the template name and outfile are not set. BugId: 45258

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/wheeljack/lib/MT/App/CMS.pm

    r851 r852  
    49154915    } 
    49164916 
     4917    return $app->errtrans('The Template Name and Output File fields are required.') 
     4918        if $type eq 'template' && !$q->param('name') && !$q->param('outfile'); 
     4919 
    49174920    if ($type eq 'author') { 
    49184921        ## If we are saving an author profile, we need to do some 
  • branches/wheeljack/tmpl/cms/edit_template.tmpl

    r774 r852  
    8282    initDirty(); 
    8383} 
     84 
     85function validate (f, rebuild) { 
     86    if (!f.name.value) { 
     87        alert('<MT_TRANS phrase="You must set the Template Name." escape="singlequotes">'); 
     88        return false; 
     89    } 
     90    else if (!f.outfile.value) { 
     91        alert('<MT_TRANS phrase="You must set the template Output File." escape="singlequotes">'); 
     92        return false; 
     93    } 
     94    else { 
     95        clearDirty(); 
     96        if (rebuild) setRebuild(f); 
     97    } 
     98} 
    8499//--> 
    85100</script> 
     
    251266</div> 
    252267 
    253 <input accesskey="s" type="submit" value="<MT_TRANS phrase="Save">" title="<MT_TRANS phrase="Save this template (s)">" onclick="clearDirty()" /> 
     268<input accesskey="s" type="submit" value="<MT_TRANS phrase="Save">" title="<MT_TRANS phrase="Save this template (s)">" onclick="return validate(this.form);" /> 
    254269<TMPL_UNLESS NAME=NEW_OBJECT> 
    255270<TMPL_UNLESS NAME=BUILD_DYNAMIC> 
    256271<TMPL_IF NAME=HAS_REBUILD> 
    257272<TMPL_IF NAME=CAN_REBUILD> 
    258 <input type="submit" value="<MT_TRANS phrase="Save and Rebuild">" accesskey="r" title="<MT_TRANS phrase="Save and rebuild this template (r)">" onclick="clearDirty();setRebuild(this.form)" /></TMPL_IF> 
     273<input type="submit" value="<MT_TRANS phrase="Save and Rebuild">" accesskey="r" title="<MT_TRANS phrase="Save and rebuild this template (r)">" onclick="return validate(this.form, 1);" /></TMPL_IF> 
    259274</TMPL_IF> 
    260275</TMPL_UNLESS>