Note the upgraded forum! If you are experiencing issues logging in, you may need to reset your password which should send an email. If the email doesn't arrive, be sure to check your spam folder just in case.

console error "Uncaught SyntaxError: Invalid regular expression: /{0}/: Nothing to repeat"

edited March 2016 in Bug Reports

(fuelcms feature branch)

I have the following code in a model in the form fields function, it gets a list of products for the specific manufacturer and creates links to them in the products module:

if(isset($values['make_id']) && !empty($values['make_id'])){
$fields['Models'] = array('type' => 'fieldset', 'order' => 700, 'class' => 'tab');
$this->db->select('model_id, model_name');
$models = $this->db->get_where("model", array('model_make_id'=>$values['make_id']))->result();
$order = 701;

if(isset($models) && !empty($models)){
foreach($models as $model){
$fields[$model->model_name] = array('type' => 'button',
'displayonly' => true,
'label' => "model_id}'>{$model->model_name}",
'order' => $order,

when there is only one product it throws an error in the console:

"Uncaught SyntaxError: Invalid regular expression: /{0}/: Nothing to repeat"

which is in custom_fields.js:

var regex = new RegExp('\{' + id + '\}', 'g');

while I suspect it's an issue with the way I'm putting the list together, I can't figure out what the issue it.




  • edited 2:54PM
    I think i've fixed this by changing line 534 in the custom_fields.js as follows

    var regex = new RegExp('\\{' + id + '\\}', 'g');

    I've also noticed that my 1.4 branch is behind, doh
  • edited 2:54PM
    I've updated my fuel repo and this relates to custom_fields. js line 551
  • edited 2:54PM
    Does this fix work which first checks that id exists?
    $inputs.each(function(i){ var id = ($(this).is('input[type="radio"], input[type="checkbox"]')) ? $(this).attr('name'): $(this).attr('id'); if (id){ var idArr = id.split('--'); id = idArr[idArr.length -1]; if (id){ replaceValues[id] = $(this).val(); var regex = new RegExp('\{' + id + '\}', 'g'); folder = folder.replace(regex, replaceValues[id]); } } })
  • edited 2:54PM
    that looks good. cheers
Sign In or Register to comment.