Text field won't save with paypal button code

edited May 2013 in Modules
Adding paypal button code in a text field won't save. I recall that embedded style="" might cause issues, but what's wrong with adding paypal button code? Is there a fix for this?

http://hokudi.com/screenshot.png

Comments

  • edited 9:37AM
    CKEditor doesn't like inline styles. I would recommend adding the following to your paypal_button field to remove CKEditor for that field:
    $fields['paypal_button']['class'] = 'no_editor';
  • edited 9:37AM
    I tried that with the following code:
    
    function form_fields($values = array())
        {
            $fields = parent::form_fields($values);
    
            // ******************* ADD CUSOM FORM STUFF HERE *******************
    		$fields['paypal_button']['class'] = 'no_editor';
    		
            return $fields;
        }
    
    I tried saving it and it still doesn't work...

    http://hokudi.com/screenshot_2.png

    I'm thinking it has to do with validations happening on the data?
  • edited 9:37AM
    Try adding the following to your module's config in MY_fuel_modules.php:
    'sanitize_input' => array('template','php')
    By default, the xss_clean function is applied to fields which can cause issues sometimes. Adding the above will remove that filter.
  • edited 9:37AM
    Dave,

    I actually tried something similar to that earlier. It didn't work. I tried:
    
    $config['modules']['courses_courses'] = array(
    	..
    	'sanitize_input' => array('template','php')
    );
    
    and
    
    $config['modules']['courses_courses'] = array(
    	..
    	'sanitize_input' => false
    );
    
  • edited 9:37AM
    FYI, something as simple as will cause it to not save. I'm sure it's got to do with some filtering... I'll take a look around to see what could be causing the issue, but if you have any idea, please let me know.
  • edited 9:37AM
    correction: something as simple as
    <input>
  • edited 9:37AM
    When you say it won't save do you mean that it blanks out the contents of that field or that the changes to the field don't get saved? Have you found certain characters causing problems?
  • edited May 2013
    RE: When you say it won't save do you mean that it blanks out the contents of that field or that the changes to the field don't get saved?

    Changes to the field doesn't get saved. It doesn't save other fields as well if I try to save paypal button code. For example, I have two fields (1) price and (2) paypal_button. If I put in a valid price and paypal button code, the result is none of the fields are saved.

    I know my form works fine because if I put in a valid price and leave the paypal button code out, it will save the price. So, I know the issue is with the paypal button code.

    Have you found certain characters causing problems?
    Yes, I've confirmed that the following html tag will cause the form to not save at all:
    <input>
  • edited 9:37AM
    Hmm... are you using any model hooks? Perhaps add something like the following in an on_before_validate hook which will run the validation before saving and tell you if there are any errors preventing it from saving:
    function on_before_validate($values){ $this->validate(); echo '<pre>'; print_r($this->get_errors()); echo '</pre>'; exit(); }
  • edited 9:37AM
    I'm not using any hooks. I also tried the on_before_validate suggestion. I don't see anything wrong with it.

    I have a bare bones setup. It's a simple module with no added tweaks.

    INTERESTING FIND:
    When I change the database field name from "paypal_button" to "comments2," it works! If I name it "test" or "test2," it doesn't work! I also tried renaming it to something completely random like "asdf," and it still doesn't work! It works for "comments" and "comments2" though!

    What could possibly be causing this??
  • edited 9:37AM
    ADDITIONAL FIND:
    I figured if I change the database field name to "content" similar to the blog post module, it would work (don't know why I thought this). I did and it did work! I also tried naming it "paypal_content" and it worked also......
  • edited 9:37AM
    That is strange and I don't have an answer for that right now. I would have to debug the model or perhaps MY_Model::save method around line 1444 to see what the $values are being set to save.
Sign In or Register to comment.