mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 12:48:26 +02:00
Issue #539 - validation of user-extended elements will automatically switch tabs when an error is found.
This commit is contained in:
@@ -267,6 +267,8 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
{
|
{
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
$frm = e107::getForm();
|
||||||
|
|
||||||
|
|
||||||
$qry = "
|
$qry = "
|
||||||
SELECT * FROM #user_extended_struct
|
SELECT * FROM #user_extended_struct
|
||||||
@@ -428,7 +430,7 @@ class usersettings_shortcodes extends e_shortcode
|
|||||||
if(defined($fname)) $fname = constant($fname);
|
if(defined($fname)) $fname = constant($fname);
|
||||||
$fname = $tp->toHTML($fname, "", "emotes_off, defs");
|
$fname = $tp->toHTML($fname, "", "emotes_off, defs");
|
||||||
|
|
||||||
if($fInfo['user_extended_struct_required'] == 1)
|
if($fInfo['user_extended_struct_required'] == 1 && !deftrue('BOOTSTRAP'))
|
||||||
{
|
{
|
||||||
$fname = str_replace("{FIELDNAME}", $fname, $REQUIRED_FIELD);
|
$fname = str_replace("{FIELDNAME}", $fname, $REQUIRED_FIELD);
|
||||||
}
|
}
|
||||||
|
@@ -208,6 +208,11 @@ class e_form
|
|||||||
$c = 0;
|
$c = 0;
|
||||||
foreach($array as $key=>$tab)
|
foreach($array as $key=>$tab)
|
||||||
{
|
{
|
||||||
|
if(is_numeric($key))
|
||||||
|
{
|
||||||
|
$key = 'tab-'.$this->name2id($tab['caption']);
|
||||||
|
}
|
||||||
|
|
||||||
$active = ($c == 0) ? ' class="active"' : '';
|
$active = ($c == 0) ? ' class="active"' : '';
|
||||||
$text .= '<li'.$active.'><a href="#'.$key.'" data-toggle="tab">'.$tab['caption'].'</a></li>';
|
$text .= '<li'.$active.'><a href="#'.$key.'" data-toggle="tab">'.$tab['caption'].'</a></li>';
|
||||||
$c++;
|
$c++;
|
||||||
@@ -222,6 +227,11 @@ class e_form
|
|||||||
$c=0;
|
$c=0;
|
||||||
foreach($array as $key=>$tab)
|
foreach($array as $key=>$tab)
|
||||||
{
|
{
|
||||||
|
if(is_numeric($key))
|
||||||
|
{
|
||||||
|
$key = 'tab-'.$this->name2id($tab['caption']);
|
||||||
|
}
|
||||||
|
|
||||||
$active = ($c == 0) ? ' active' : '';
|
$active = ($c == 0) ? ' active' : '';
|
||||||
$text .= '<div class="tab-pane'.$active.'" id="'.$key.'">'.$tab['text'].'</div>';
|
$text .= '<div class="tab-pane'.$active.'" id="'.$key.'">'.$tab['text'].'</div>';
|
||||||
$c++;
|
$c++;
|
||||||
|
@@ -676,6 +676,7 @@ class e107_user_extended
|
|||||||
$regexfail = $tp->toText($parms[2]);
|
$regexfail = $tp->toText($parms[2]);
|
||||||
$fname = "ue[user_".$struct['user_extended_struct_name']."]";
|
$fname = "ue[user_".$struct['user_extended_struct_name']."]";
|
||||||
$required = vartrue($struct['user_extended_struct_required']) ? "required" : "";
|
$required = vartrue($struct['user_extended_struct_required']) ? "required" : "";
|
||||||
|
$fid = $frm->name2id($fname);
|
||||||
|
|
||||||
if(strpos($include, 'class') === FALSE)
|
if(strpos($include, 'class') === FALSE)
|
||||||
{
|
{
|
||||||
@@ -687,7 +688,7 @@ class e107_user_extended
|
|||||||
{
|
{
|
||||||
case EUF_TEXT : //textbox
|
case EUF_TEXT : //textbox
|
||||||
case EUF_INTEGER : //integer
|
case EUF_INTEGER : //integer
|
||||||
$ret = "<input name='{$fname}' value='{$curval}' {$include} {$required} />";
|
$ret = "<input id='{$fid}' name='{$fname}' value='{$curval}' {$include} {$required} />";
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
break;
|
break;
|
||||||
@@ -722,7 +723,7 @@ class e107_user_extended
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$chk = ($curval == $val)? " checked='checked' " : "";
|
$chk = ($curval == $val)? " checked='checked' " : "";
|
||||||
$ret .= "<input {$include} type='radio' name='{$fname}' value='{$val}' {$chk} {$required} /> {$label}";
|
$ret .= "<input id='{$fid}' {$include} type='radio' name='{$fname}' value='{$val}' {$chk} {$required} /> {$label}";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -766,7 +767,7 @@ class e107_user_extended
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EUF_DROPDOWN : //dropdown
|
case EUF_DROPDOWN : //dropdown
|
||||||
$ret = "<select {$include} name='{$fname}' {$required} >\n";
|
$ret = "<select {$include} id='{$fid}' name='{$fname}' {$required} >\n";
|
||||||
$ret .= "<option value=''> </option>\n"; // ensures that the user chose it.
|
$ret .= "<option value=''> </option>\n"; // ensures that the user chose it.
|
||||||
foreach($choices as $choice)
|
foreach($choices as $choice)
|
||||||
{
|
{
|
||||||
@@ -790,7 +791,7 @@ class e107_user_extended
|
|||||||
if (!method_exists($className, 'getValue')) return '???-???';
|
if (!method_exists($className, 'getValue')) return '???-???';
|
||||||
$temp->pointerReset();
|
$temp->pointerReset();
|
||||||
|
|
||||||
$ret = "<select {$include} name='{$fname}' {$required} >\n";
|
$ret = "<select id='{$fid}' {$include} name='{$fname}' {$required} >\n";
|
||||||
$ret .= "<option value=''> </option>\n"; // ensures that the user chooses it.
|
$ret .= "<option value=''> </option>\n"; // ensures that the user chooses it.
|
||||||
while (FALSE !== ($row = $temp->getValue(0, 'next')))
|
while (FALSE !== ($row = $temp->getValue(0, 'next')))
|
||||||
{
|
{
|
||||||
@@ -810,7 +811,7 @@ class e107_user_extended
|
|||||||
|
|
||||||
if($sql->db_Select($tp -> toDB($choices[0], true), $tp -> toDB($choices[1], true).",".$tp -> toDB($choices[2], true), "1 $order")){
|
if($sql->db_Select($tp -> toDB($choices[0], true), $tp -> toDB($choices[1], true).",".$tp -> toDB($choices[2], true), "1 $order")){
|
||||||
$choiceList = $sql->db_getList('ALL',FALSE);
|
$choiceList = $sql->db_getList('ALL',FALSE);
|
||||||
$ret = "<select {$include} name='{$fname}' {$required} >\n";
|
$ret = "<select id='{$fid}' {$include} name='{$fname}' {$required} >\n";
|
||||||
$ret .= "<option value=''> </option>\n"; // ensures that the user chose it.
|
$ret .= "<option value=''> </option>\n"; // ensures that the user chose it.
|
||||||
foreach($choiceList as $cArray)
|
foreach($choiceList as $cArray)
|
||||||
{
|
{
|
||||||
@@ -827,7 +828,7 @@ class e107_user_extended
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EUF_TEXTAREA : //textarea
|
case EUF_TEXTAREA : //textarea
|
||||||
return "<textarea {$include} name='{$fname}' {$required} >{$curval}</textarea>";
|
return "<textarea id='{$fid}' {$include} name='{$fname}' {$required} >{$curval}</textarea>";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case EUF_DATE : //date
|
case EUF_DATE : //date
|
||||||
@@ -844,7 +845,7 @@ class e107_user_extended
|
|||||||
$lanlist = e107::getLanguage()->installed();
|
$lanlist = e107::getLanguage()->installed();
|
||||||
sort($lanlist);
|
sort($lanlist);
|
||||||
|
|
||||||
$ret = "<select {$include} name='{$fname}' {$required} >\n";
|
$ret = "<select {$include} id='{$fid}' name='{$fname}' {$required} >\n";
|
||||||
$ret .= "<option value=''> </option>\n"; // ensures that the user chose it.
|
$ret .= "<option value=''> </option>\n"; // ensures that the user chose it.
|
||||||
foreach($lanlist as $choice)
|
foreach($lanlist as $choice)
|
||||||
{
|
{
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
|
/* global $ */
|
||||||
|
|
||||||
$(document).ready(function()
|
$(document).ready(function()
|
||||||
{
|
{
|
||||||
@@ -264,7 +264,7 @@ $(document).ready(function()
|
|||||||
|
|
||||||
if(!a.error)
|
if(!a.error)
|
||||||
{
|
{
|
||||||
//TODO modify status of html on page.
|
//TODO modify status of html on page
|
||||||
$(id).text(a.html)
|
$(id).text(a.html)
|
||||||
.fadeIn('slow')
|
.fadeIn('slow')
|
||||||
.addClass('e-comment-edit-success'); //TODO another class?
|
.addClass('e-comment-edit-success'); //TODO another class?
|
||||||
@@ -303,7 +303,7 @@ $(document).ready(function()
|
|||||||
dataType: "html",
|
dataType: "html",
|
||||||
success: function(html) {
|
success: function(html) {
|
||||||
|
|
||||||
if(html == '')
|
if(html === '')
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -323,4 +323,30 @@ $(document).ready(function()
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Switch to Tab containing invalid form field. */
|
||||||
|
$('input[type=submit],button[type=submit]').on('click', function() {
|
||||||
|
|
||||||
|
var id = $(this).closest('form').attr('id'), found = false;
|
||||||
|
|
||||||
|
$('#'+ id).find(':invalid').each(function (index, node) {
|
||||||
|
|
||||||
|
var tab = $('#'+node.id).closest('.tab-pane').attr('id');
|
||||||
|
// console.log(node.id);
|
||||||
|
|
||||||
|
if(tab && (found === false))
|
||||||
|
{
|
||||||
|
$('a[href="#'+tab+'"]').tab('show');
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
Reference in New Issue
Block a user