WordPress.org

Forums

Custom Content Type Manager
[resolved] Value of 0 in a required text field (15 posts)

  1. mbi_marc
    Member
    Posted 2 years ago #

    Hey there. I love this plugin-it's a total lifesaver. I've come across what I assume to be a bug; if I try to enter a value of 0 into a required text field, I cannot publish the post, as it returns a message that the field is required.

    Is there a fix for this behavior?

    Thanks!

    http://wordpress.org/extend/plugins/custom-content-type-manager/

  2. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    Yes, I think that's already been fixed in the dev version (download it from the "other versions" area of the plugin page). See the bug-tracker for info on the bug, including the SVN revision number of when it was fixed.

  3. mbi_marc
    Member
    Posted 2 years ago #

    Sorry for re-opening this, but I'm having difficulty finding the bug in the bug tracker, and the newest version released today doesn't seem to include a fix for this. I'm wary of using the dev version because, well, it's a dev version.

    The closest thing I can find in the bug tracker is issue #374, which is related but not quite the same. As per that issue, a value of 000000 is correctly allowed (and this does work for me), but a value of simply a single 0 is still not working for me.

    I'm not able to set this field to a number, as the value can either be numeric or a descriptive string (such as "variable") depending on the specific item.

    Have I missed the correct issue in the tracker?

  4. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    0 evaluates to empty, so if the field is required, it needs a non-zero value.

  5. mbi_marc
    Member
    Posted 2 years ago #

    0 evaluates to empty, but there are ways of differentiating a string '0' from empty if you try (such as an === comparison, or using isset() ). Is the issue that the code doesn't take the field type into account at all when checking for a value? Shouldn't text and textarea fields be tested against as a string?

    As a separate question, if I were to try to fix this myself, is function get_value() in includes/CCTM_FormElement.php the correct place to do it? I'm not familiar with your code at all, so having a starting point would save me a ton of time!

    Thanks in advance.

  6. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    You're welcome to look through the code -- it's well-commented and the bug tracker lists exactly where this issue was. This problem is really difficult because the value is going through POST and through json encoding, so it is always set (i.e. isset is useless), and values are always typed as strings (so === is useless). So really what you're asking for is that "required" fields must contain ANY non-whitespace value, i.e. a strlen > 0, but I'm not sure that's the correct solution.

  7. mbi_marc
    Member
    Posted 2 years ago #

    I'm not sure that this holds up as well for other field types, but specifically for text/textarea, I'm not sure what else required would mean, if you've given no validation rule.

    Did they type something in? Yes.
    Does it match the rule of <absolutely no rules at all>? Yes.
    Validation passed!

    If there weren't a validation rule option, this would be less clear cut, but there is, so...

  8. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    I've reopened the ticket.

  9. vanadium322
    Member
    Posted 2 years ago #

    I'm having the same problem. Trying to save a record with '0' as a value will not give any error messages for me, but it will force the post into draft status.

  10. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    Please refer to the latest version of the plugin. Version 0.9.7.3 was released a couple hours ago. The forums are a difficult place to discuss stuff like this because there's no accountability and there's a lack of details like the specific version number. If you have downloaded the latest version and you still are having this problem, then please file a bug in the bug tracker: it taxes my sanity trying to shepherd random forum comments into bug reports or feature requests.

  11. vanadium322
    Member
    Posted 2 years ago #

    This was immediately after upgrading to 0.9.7.3. Sorry, I didn't know there was a bug tracker. I'll try to find it.

  12. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    There's a bug tracker and a wiki, both conspicuously linked on the plugin's homepage and from the WP manager on any CCTM page.

  13. mbi_marc
    Member
    Posted 2 years ago #

    I'm seeing the same thing- no more error messages, but still can't publish it. I don't see a new bug posted by vanadum322, so I made a comment on issue 374 (the one previously used for this). If you'd prefer I post a new one, I can do that- just not sure of normal protocol here.

  14. fireproofsocks
    Member
    Plugin Author

    Posted 2 years ago #

    See the bug tracker. I"m losing my mind switching between the forums and the bug tracker: https://code.google.com/p/wordpress-custom-content-type-manager/issues/detail?id=374

  15. Jerome
    Member
    Posted 2 years ago #

    Works perfectly since last update ( 0.9.7.5-pl )
    thanks !

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Custom Content Type Manager
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic