[resolved] JSColor color picker intergrate problem (3 posts)

  1. junglized
    Posted 3 years ago #

    Hi everyone!

    I started creating a theme, and I encountered a serious problem, as I'm not an advanced JS or PHP programmer. A color value after clicking "save" is not actually saved for my color picker. Every other field, no matter it's a text field, text area, radio button or else is being saved properly, except unfortunate color picker field. I downloaded my picker from http://jscolor.com/. Maybe there is someone who could help me a bit.

    few code samples:

    field settings -

    array( "name" => "Bg Color",
    "desc" => "#abcd01.",
    "id" => $shortname."_background",
    "type" => "picker",
    "std" => "abcdef"),

    input settings -

    case 'picker': ?>
    <tr><td><p><label for="<?php echo $value['id']; ?>"><?php echo $value['name']; ?></label></p></td>
    <td><p><input <input name="<?php echo $value['id']; ?>" id="<?php echo $value['id']; ?>" type="<?php echo $value['type']; ?>" value="<?php if ( get_settings( $value['id'] ) != "") { echo stripslashes(get_settings( $value['id'])  ); } else { echo $value['std']; } ?>" class="color" />
    <small><?php echo $value['desc']; ?></small></p></td></tr>
    <?php break;

    save function settings -

    [ Moderator Note: Please post code or markup snippets between backticks or use the code button. Single quote does not work. ]

    function theme_settings_page() {
    	global $themename,$theme_options;
    		if ( 'save' == $_REQUEST['action'] ) {
    			foreach ($theme_options as $value) {
    		update_option( $value['id'], $_REQUEST[ $value['id'] ] ); }
    			foreach ($theme_options as $value) {
    		if( isset( $_REQUEST[ $value['id'] ] ) ) { update_option( $value['id'], $_REQUEST[ $value['id'] ]  ); } else { delete_option( $value['id'] ); } }
    else if( 'reset' == $_REQUEST['action'] ) {
    			foreach ($theme_options as $value) {
    		delete_option( $value['id'] ); }
    		if ( $message=='saved' && $i==0 )  echo '<div id="message" class="apply"><strong>Ustawienia zachowane.</strong></div>' ;
    		if ( $message=='reset' ) echo '<div id="message" class="reset"><strong>Ustawienia zresetowane.</strong></div>';
  2. junglized
    Posted 3 years ago #

    I need to specify my previous post, picker is displayed correctly, everything works fine, but after saving value in text field goes back to initial value, which is stored as 'std'.

  3. junglized
    Posted 3 years ago #

    Nevermind, other text field had the same id, I didn't notice until now, problem fixed!

Topic Closed

This topic has been closed to new replies.

About this Topic