LeanAdmin / feature-discussions

The place for discussing new features
6 stars 0 forks source link

Link field #19

Closed gavinhewitt closed 2 years ago

gavinhewitt commented 3 years ago

Would be nice to make the text a link to an action:

Text::make('text')
    ->label('This is a clickable title')
    ->rules('max:255')
    ->linkTo('edit') // or other action
,
stancl commented 3 years ago

I was just about to open an issue like this. Though a bit more generic - readonly Link fields.

Right now I'm doing this:

Text::make('Preview')
    ->resolveValueUsing(fn (Text $field) => route('docs.page', $field->form['slug']->value))
    ->renderAs(fn ($field, $value) => "<a target='_blank' class='styled' href='{$value}'>Preview</a>")
    ->stored(false),
stancl commented 3 years ago

Done in dev-master.