Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Link is not saved (CF 3) #7

Closed
KevinSupertramp opened this issue Mar 3, 2019 · 10 comments
Closed

Link is not saved (CF 3) #7

KevinSupertramp opened this issue Mar 3, 2019 · 10 comments
Labels

Comments

@KevinSupertramp
Copy link

Hi there,

Firstly, thank you for the plugin! I'm trying to use it with the latest version of Carbon Fields but the link is not saved nor selected after clicking on "Add Link".

Kind regards,

@iamntz
Copy link
Owner

iamntz commented Mar 4, 2019

Hey Kevin. Unfortunately I can't replicate your issue. Are you sure you're on the branch v3 ?

@iamntz
Copy link
Owner

iamntz commented Mar 4, 2019

You can either update your composer.json file to read:

"require": {
  "iamntz/carbon-fields-urlpicker": "v3.x-dev"
}

Or install it via cli:

composer require iamntz/carbon-fields-urlpicker:v3.x-dev

@KevinSupertramp
Copy link
Author

Hi @iamntz ,

Thanks for your quick reply and yes I am using the v3. The field is used in a Gutenberg block (CF_Block). I don't get any error in the console either.

I just tried in a "theme_options" container and it works. It looks like it might be related when it is used in a block container?

Best regards,

@iamntz
Copy link
Owner

iamntz commented Mar 4, 2019

Mmmm, I didn't used Carbon as a gutenberg block until now. I'll dig into it and I'll let you know :)

@KevinSupertramp
Copy link
Author

@iamntz That's awesome, thanks so much!

@iamntz
Copy link
Owner

iamntz commented Mar 4, 2019

From what i can see, the data is saved. Is just that... the button isn't updated. Well, I assume combining legacy with new is not always the best idea 🗡

  Block::make( 'ntz/urlpicker-test', __( 'URL Picker test' ) )
      ->add_fields( array(
          Field::make( 'urlpicker', 'urlpicker', __( 'Block URL' ) ),
      ) )
      ->set_render_callback( function ( $fields, $attributes = null, $inner_blocks = null ) {
          echo '<pre>';
              print_r( $fields );
              print_r( $attributes );
              print_r( $inner_blocks );
          echo '</pre>';
      } );

Will update in a bit.

@iamntz
Copy link
Owner

iamntz commented Mar 4, 2019

Unfortunately, it seems that there is an issue with WP core itself:

WordPress/gutenberg#11432

So for now this will be no stand by.

@KevinSupertramp
Copy link
Author

KevinSupertramp commented Mar 4, 2019

Hi, oh okay. I think they applied the fix in 5.1?

Anyway, I realised that the data is saved but the field id (key) is not used, instead it's the auto-generated CF I guess? Maybe this is why the data is not loaded? (In my case it should be "cta" instead of carbon-12e5c)

screen shot 2019-03-04 at 10 24 43

iamntz added a commit that referenced this issue Mar 4, 2019
- fix field name on gutenberg blocks
@iamntz
Copy link
Owner

iamntz commented Mar 4, 2019

Ups, that was my mistake. Which is fixed now :)

@gaambo
Copy link

gaambo commented Sep 5, 2019

Hi there, I had a similar problem/bug - the value was saved but not shown/editable in the backend. Seems there was a bug how the value was accessed via the field props (or maybe carbon fields api changed). Made a pull request - just some minor changes, so should be good to go.

Edit: I read through all the gutenberg/core issues referenced here. Seems they are not really happy about the situation with using the "old" wpLink component in gutenberg. Also all linkable core blocks (image, button) use other UIs for handling links. Maybe we should keep an eye on these issues to see if the api changes.

Offtopic: When editing I didn't quite get why you overwrote the setDefaultValues method of wpLink (thought this caused the bug, no usage of the component in core does that). Maybe that could be reworked/documented? I'd be happy to help here. A URL-/link-field is one of my most used fields in ACF and I'd like to make the switch, so ensuring there's a proper alternative is worth some effort from my side :) Thanks for your work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants