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

Field Manager not working on the front end #804

Open
nicoladj77 opened this issue May 8, 2021 · 2 comments
Open

Field Manager not working on the front end #804

nicoladj77 opened this issue May 8, 2021 · 2 comments
Labels
enhancement New feature or request reporter-feedback

Comments

@nicoladj77
Copy link

I've been using Field Manager to display forms on the front end. It works pretty well, but that requires manually changing the files, as javascript/css is not loaded on the front end. Would it be possible to add a filter so that it's possible to use Fieldmanager on the front end if needed?

@dlh01
Copy link
Member

dlh01 commented May 8, 2021

Hi @nicoladj77 — could you please share an example of the code that's used to load fields on the frontend and an example of the change to files that's necessary to get static assets to load?

Distantly related: #157

@dlh01 dlh01 added enhancement New feature or request reporter-feedback labels May 8, 2021
@nicoladj77
Copy link
Author

@dlh01 to load fields on the front end I use

	$field_value = '';
	if ( $options['load_values'] ) {
		$field_value = self::get_question_answer( $question->ID, $options['grant_request_id'] );
	}
	$name            = 'question_' . $question->ID;
	$question_fields = get_post_meta( $question->ID, 'question-fields', true );
	$attributes      = [];
	if ( $options['readonly'] ) {
		$attributes['disabled'] = 'disabled';
	}
	if ( isset( $question_fields['correct-answer'] ) ) {
		$attributes['data-correct'] = $question_fields['correct-answer'];
	}

	$fm = new \Fieldmanager_Radios(
		$question->post_title,
		[
			'name'        => $name,
			'description' => $question->post_excerpt,
			'options'     => [
				'yes' => __( 'Yes', '' ),
				'no'  => __( 'No', '' ),
			],
			'required'    => true,
			'attributes'  => $attributes,
			'escape'      => [ 'description' => 'wp_kses_post' ],
		]
	);
	echo $fm->element_markup( $field_value ); // phpcs:ignore

While the issue in code is on this line https://github.com/alleyinteractive/wordpress-fieldmanager/blob/main/php/util/class-fieldmanager-util-assets.php#L186
I guess you could wrap the is_admin call in a filter and it would be possible to override it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request reporter-feedback
Projects
None yet
Development

No branches or pull requests

2 participants