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

Feature Request: Configurable field type/schema #1

Open
fthues opened this issue Apr 11, 2019 · 2 comments
Open

Feature Request: Configurable field type/schema #1

fthues opened this issue Apr 11, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@fthues
Copy link

fthues commented Apr 11, 2019

Thanks for the plugin!

It would be great to be able to define the database column type of the readonly field. Right now it's hardcoded to Schema::TYPE_STRING, but we need Schema::TYPE_INTEGER instead.

@kringkaste kringkaste added the enhancement New feature or request label Apr 12, 2019
@kringkaste
Copy link
Member

Yeah, we've been thinking about that, too. But then you will have to offer Float as well. And in both cases you need a way to define the format for the output, right?

@kringkaste kringkaste self-assigned this Apr 12, 2019
@skeemer
Copy link

skeemer commented Aug 18, 2022

This issue is pretty old, but it helped me figure out how to create the field I needed (Schema::TYPE_TEXT) for content length. I just extended the class with what I needed. I'm throwing this here in case someone else needs something similar.

<?php

namespace modules\fields;

use Craft;
use yii\db\Schema;

class ReadonlyTextField extends \codemonauts\readonly\fields\ReadonlyField
{
    public string $columnType = Schema::TYPE_TEXT;

    public static function displayName(): string
    {
        return Craft::t('app', 'Read-only Field (Large)');
    }
}

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

No branches or pull requests

3 participants