Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Oil enum error - enhancement maybe
  • Hi,

    Using oil and the enum type I was getting an error on this enum:

    cron_type:enum[batch,non-batch,stop]

    The enum datatype will not allow any type of word separators like - _ etc;

    This doe's work:

    cron_type:enum[batch,nonbatch,stop]

    But we should be able to separate multiple words in an enum.

    Thank you

  • I think the problem with the minus sign isn't oil, but the fact that your shell sees it as a command delimiter.

    The code does this, it really splits on the comma only:

    if ($type === 'enum')
    {
        $values = explode(',', $option[1]);
        $option[1] = '"'.implode('","', $values).'"';

        $field_array['constraint'] = $option[1];
    }

  • Why will it not accept an underscore or a space then? I can enter them in the field name using git bash.

    Oil generate line 683:
    preg_match('/([a-z0-9_-]+)(?:\[([0-9a-z\,\s]+)\])?/i', $part, $part_matches);

    RegExp: /([a-z0-9_-]+)(?:\[([0-9a-z\,\s]+)\])?/i
    pattern: ([a-z0-9_-]+)(?:\[([0-9a-z\,\s]+)\])?
    flags: i
    2 capturing groups: 
       group 1: ([a-z0-9_-]+)     <-- field name
       group 2: ([0-9a-z\,\s]+)   <-- field value - this is not allowing for the underscore.

    This is FuelPHP 1.7 dev

  • HarroHarro
    Accepted Answer
    Ah, there's a regex before that. I don't think it should be a problem to expand that. Could you create an issue for this at https://github.com/fuel/oil/issues ?
  • Issue created thank you Harro

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion